Zelda Classic Coverage Report


Directory: src/
File: src/qst.cpp
Date: 2023-08-06 03:53:11
Exec Total Coverage
Lines: 8338 12128 68.8%
Functions: 93 126 73.8%
Branches: 5469 10295 53.1%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // ZQuest Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // qst.cc
6 //
7 // Code for loading '.qst' files in ZC and ZQuest.
8 //
9 //--------------------------------------------------------
10
11 #include "allegro/file.h"
12 #include "base/util.h"
13 #include "base/zapp.h"
14 #include "base/qrs.h"
15 #include "base/cpool.h"
16 #include "base/packfile.h"
17
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 #include "base/dmap.h"
18 #include "base/combo.h"
19 #include "base/msgstr.h"
20 #include <filesystem>
21 #include <stdio.h>
22 #include <string.h>
23 #include <string>
24 #include <map>
25 #include <vector>
26 #include <assert.h>
27 #include <fmt/format.h>
28
29
30 #include "metadata/sigs/devsig.h.sig"
31 #include "metadata/sigs/compilersig.h.sig"
32 #include "metadata/versionsig.h"
33 #include "base/zc_alleg.h"
34 #include "base/zdefs.h"
35 #include "base/colors.h"
36 #include "tiles.h"
37 #include "base/zsys.h"
38 #include "qst.h"
39 #include "defdata.h"
40 #include "subscr.h"
41 #include "font.h"
42 #include "zc/replay.h"
43 #include "zc/zc_custom.h"
44 #include "sfx.h"
45 #include "md5.h"
46 #include "zinfo.h"
47 #include "zc/ffscript.h"
48 #include "particles.h"
49 #include "dialog/alert.h"
50 #include "base/misctypes.h"
51
52 #ifdef __EMSCRIPTEN__
53 #include "base/emscripten_utils.h"
54 #endif
55
56 //FFScript FFCore;
57 extern FFScript FFCore;
58 extern ZModule zcm;
59 extern zcmodule moduledata;
60 extern uint8_t __isZQuest;
61 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
62 extern particle_list particles;
63 extern void setZScriptVersion(int32_t s_version);
64 //FFSCript FFEngine;
65
66 int32_t temp_ffscript_version = 0;
67 static bool read_ext_zinfo = false, read_zinfo = false;
68 static bool loadquest_report = false;
69 static char const* loading_qst_name = NULL;
70 static byte loading_qst_num = 0;
71
72 int32_t First[MAX_COMBO_COLS]={0},combo_alistpos[MAX_COMBO_COLS]={0},combo_pool_listpos[MAX_COMBO_COLS]={0};
73 map_and_screen map_page[MAX_MAPPAGE_BTNS]= {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
74
75 #ifdef _MSC_VER
76 #define strncasecmp _strnicmp
77 #endif
78
79 #ifndef _AL_MALLOC
80 #define _AL_MALLOC(a) _al_malloc(a)
81 #define _AL_FREE(a) _al_free(a)
82 #endif
83
84 using std::string;
85 using std::pair;
86
87 // extern bool debug;
88 extern int32_t hero_animation_speed; //lower is faster animation
89 extern std::vector<mapscr> TheMaps;
90 extern std::vector<word> map_autolayers;
91 extern zcmap *ZCMaps;
92 extern byte *colordata;
93 //extern byte *tilebuf;
94 extern tiledata *newtilebuf;
95 extern byte *trashbuf;
96 extern itemdata *itemsbuf;
97 extern wpndata *wpnsbuf;
98 extern comboclass *combo_class_buf;
99 extern guydata *guysbuf;
100 extern ZCHEATS zcheats;
101 extern zinitdata zinit;
102 extern char palnames[MAXLEVELS][17];
103 extern int32_t memrequested;
104 extern char *byte_conversion(int32_t number, int32_t format);
105 extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
106 46 string zScript;
107 46 std::map<int32_t, script_slot_data > ffcmap;
108 46 std::map<int32_t, script_slot_data > globalmap;
109 46 std::map<int32_t, script_slot_data > genericmap;
110 46 std::map<int32_t, script_slot_data > itemmap;
111 46 std::map<int32_t, script_slot_data > npcmap;
112 46 std::map<int32_t, script_slot_data > ewpnmap;
113 46 std::map<int32_t, script_slot_data > lwpnmap;
114 46 std::map<int32_t, script_slot_data > playermap;
115 46 std::map<int32_t, script_slot_data > dmapmap;
116 46 std::map<int32_t, script_slot_data > screenmap;
117 46 std::map<int32_t, script_slot_data > itemspritemap;
118 46 std::map<int32_t, script_slot_data > comboscriptmap;
119 void free_newtilebuf();
120 bool combosread=false;
121 bool mapsread=false;
122 bool fixffcs=false;
123 bool fixpolsvoice=false;
124
125
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 const std::string script_slot_data::DEFAULT_FORMAT = "%s %s";
126
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 const std::string script_slot_data::INVALID_FORMAT = "%s --%s";
127
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 const std::string script_slot_data::DISASSEMBLED_FORMAT = "%s ++%s";
128
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 const std::string script_slot_data::ZASM_FORMAT = "%s ==%s";
129
130 char qstdat_string[2048] = { 0 };
131
132 static zinfo* load_tmp_zi = NULL;
133
134 int32_t memDBGwatch[8]= {0,0,0,0,0,0,0,0}; //So I can monitor memory crap
135 const byte clavio[9]={97,109,111,110,103,117,115,0};
136
137 //enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
138 // qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
139
140 const char *qst_error[] =
141 {
142 "OK","File not found","Invalid quest file",
143 "Version not supported","Obsolete version",
144 "Missing new data" , /* but let it pass in ZQuest */
145 "Internal error occurred", "Invalid password",
146 "Doesn't match saved game", "Save file is for older version of quest; please start new save",
147 "Out of memory", "File Debug Mode", "Canceled", "", "No quest assigned"
148 };
149
150 //for legacy quests -DD
151 enum { ssiBOMB, ssiSWORD, ssiSHIELD, ssiCANDLE, ssiLETTER, ssiPOTION, ssiLETTERPOTION, ssiBOW, ssiARROW, ssiBOWANDARROW, ssiBAIT, ssiRING, ssiBRACELET, ssiMAP,
152 ssiCOMPASS, ssiBOSSKEY, ssiMAGICKEY, ssiBRANG, ssiWAND, ssiRAFT, ssiLADDER, ssiWHISTLE, ssiBOOK, ssiWALLET, ssiSBOMB, ssiHCPIECE, ssiAMULET, ssiFLIPPERS,
153 ssiHOOKSHOT, ssiLENS, ssiHAMMER, ssiBOOTS, ssiDIVINEFIRE, ssiDIVINEESCAPE, ssiDIVINEPROTECTION, ssiQUIVER, ssiBOMBBAG, ssiCBYRNA, ssiROCS, ssiHOVERBOOTS,
154 ssiSPINSCROLL, ssiCROSSSCROLL, ssiQUAKESCROLL, ssiWHISPRING, ssiCHARGERING, ssiPERILSCROLL, ssiWEALTHMEDAL, ssiHEARTRING, ssiMAGICRING, ssiSPINSCROLL2,
155 ssiQUAKESCROLL2, ssiAGONY, ssiSTOMPBOOTS, ssiWHIMSICALRING, ssiPERILRING, ssiMAX
156 };
157
158 static byte deprecated_rules[QUESTRULES_NEW_SIZE];
159
160
161 void delete_combo_aliases()
162 {
163 for(int32_t j(0); j<256; j++)
164 {
165 if(combo_aliases[j].combos != NULL)
166 {
167 delete[] combo_aliases[j].combos;
168 combo_aliases[j].combos=NULL;
169 }
170
171 if(combo_aliases[j].csets != NULL)
172 {
173 delete[] combo_aliases[j].csets;
174 combo_aliases[j].csets=NULL;
175 }
176 }
177
178 }
179
180 char *byte_conversion(int32_t number, int32_t format)
181 {
182 static char num_str[40];
183
184 if(format==-1) //auto
185 {
186 format=1; //bytes
187
188 if(number>1024)
189 {
190 format=2; //kilobytes
191 }
192
193 if(number>1024*1024)
194 {
195 format=3; //megabytes
196 }
197
198 if(number>1024*1024*1024)
199 {
200 format=4; //gigabytes (dude, what are you doing?)
201 }
202 }
203
204 switch(format)
205 {
206 case 1: //bytes
207 sprintf(num_str,"%db",number);
208 break;
209
210 case 2: //kilobytes
211 sprintf(num_str,"%.2fk",float(number)/1024);
212 break;
213
214 case 3: //megabytes
215 sprintf(num_str,"%.2fM",float(number)/(1024*1024));
216 break;
217
218 case 4: //gigabytes
219 sprintf(num_str,"%.2fG",float(number)/(1024*1024*1024));
220 break;
221
222 default:
223 abort();
224 break;
225 }
226
227 return num_str;
228 }
229
230 644 char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2)
231 {
232 static char num_str1[40];
233 static char num_str2[40];
234 static char num_str[80];
235
236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 644 times.
644 if(format1==-1) //auto
237 {
238 644 format1=1; //bytes
239
240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 644 times.
644 if(number1>1024)
241 {
242 644 format1=2; //kilobytes
243 644 }
244
245
2/2
✓ Branch 0 taken 460 times.
✓ Branch 1 taken 184 times.
644 if(number1>1024*1024)
246 {
247 184 format1=3; //megabytes
248 184 }
249
250
1/2
✓ Branch 0 taken 644 times.
✗ Branch 1 not taken.
644 if(number1>1024*1024*1024)
251 {
252 format1=4; //gigabytes (dude, what are you doing?)
253 }
254 644 }
255
256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 644 times.
644 if(format2==-1) //auto
257 {
258 644 format2=1; //bytes
259
260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 644 times.
644 if(number2>1024)
261 {
262 644 format2=2; //kilobytes
263 644 }
264
265
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 598 times.
644 if(number2>1024*1024)
266 {
267 598 format2=3; //megabytes
268 598 }
269
270
1/2
✓ Branch 0 taken 644 times.
✗ Branch 1 not taken.
644 if(number2>1024*1024*1024)
271 {
272 format2=4; //gigabytes (dude, what are you doing?)
273 }
274 644 }
275
276
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 460 times.
✓ Branch 3 taken 184 times.
✗ Branch 4 not taken.
644 switch(format1)
277 {
278 case 1: //bytes
279 sprintf(num_str1,"%db",number1);
280 break;
281
282 case 2: //kilobytes
283 460 sprintf(num_str1,"%.2fk",float(number1)/1024);
284 460 break;
285
286 case 3: //megabytes
287 184 sprintf(num_str1,"%.2fM",float(number1)/(1024*1024));
288 184 break;
289
290 case 4: //gigabytes
291 sprintf(num_str1,"%.2fG",float(number1)/(1024*1024*1024));
292 break;
293
294 default:
295 abort();
296 break;
297 }
298
299
2/5
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 598 times.
✗ Branch 4 not taken.
644 switch(format2)
300 {
301 case 1: //bytes
302 sprintf(num_str2,"%db",number2);
303 break;
304
305 case 2: //kilobytes
306 46 sprintf(num_str2,"%.2fk",float(number2)/1024);
307 46 break;
308
309 case 3: //megabytes
310 598 sprintf(num_str2,"%.2fM",float(number2)/(1024*1024));
311 598 break;
312
313 case 4: //gigabytes
314 sprintf(num_str2,"%.2fG",float(number2)/(1024*1024*1024));
315 break;
316
317 default:
318 abort();
319 break;
320 }
321
322 644 sprintf(num_str, "%s/%s", num_str1, num_str2);
323 644 return num_str;
324 }
325
326 char *ordinal(int32_t num)
327 {
328 static const char *ending[4] = {"st","nd","rd","th"};
329 static char ord_str[8];
330
331 char *end;
332 int32_t t=(num%100)/10;
333 int32_t n=num%10;
334
335 if(n>=1 && n<4 && t!=1)
336 end = (char *)ending[n-1];
337 else
338 end = (char *)ending[3];
339
340 sprintf(ord_str,"%d%s",num%10000,end);
341 return ord_str;
342 }
343
344 int32_t get_version_and_build(PACKFILE *f, word *version, word *build)
345 {
346 int32_t ret;
347 *version=0;
348 *build=0;
349 byte temp_map_count=map_count;
350 byte temp_midi_flags[MIDIFLAGS_SIZE];
351 memcpy(temp_midi_flags, midi_flags, MIDIFLAGS_SIZE);
352
353 zquestheader tempheader;
354
355 if(!f)
356 {
357 return qe_invalid;
358 }
359
360 ret=readheader(f, &tempheader);
361
362 if(ret)
363 {
364 return ret;
365 }
366
367 map_count=temp_map_count;
368 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
369 *version=tempheader.zelda_version;
370 *build=tempheader.build;
371 return 0;
372 }
373
374
375 bool find_section(PACKFILE *f, int32_t section_id_requested)
376 {
377
378 if(!f)
379 {
380 return false;
381 }
382
383 int32_t section_id_read;
384 bool catchup=false;
385 word dummy;
386 byte tempbyte;
387 char tempbuf[65536];
388
389
390 switch(section_id_requested)
391 {
392 case ID_RULES:
393 case ID_STRINGS:
394 case ID_MISC:
395 case ID_TILES:
396 case ID_COMBOS:
397 case ID_CSETS:
398 case ID_MAPS:
399 case ID_DMAPS:
400 case ID_DOORS:
401 case ID_ITEMS:
402 case ID_WEAPONS:
403 case ID_COLORS:
404 case ID_ICONS:
405 case ID_INITDATA:
406 case ID_GUYS:
407 case ID_MIDIS:
408 case ID_CHEATS:
409 break;
410
411 default:
412 al_trace("Bad section requested!\n");
413 return false;
414 break;
415 }
416
417 dword section_size;
418
419 //section id
420 if(!p_mgetl(&section_id_read,f))
421 {
422 return false;
423 }
424
425 while(!pack_feof(f))
426 {
427 switch(section_id_read)
428 {
429 case ID_RULES:
430 case ID_STRINGS:
431 case ID_MISC:
432 case ID_TILES:
433 case ID_COMBOS:
434 case ID_CSETS:
435 case ID_MAPS:
436 case ID_DMAPS:
437 case ID_DOORS:
438 case ID_ITEMS:
439 case ID_WEAPONS:
440 case ID_COLORS:
441 case ID_ICONS:
442 case ID_INITDATA:
443 case ID_GUYS:
444 case ID_MIDIS:
445 case ID_CHEATS:
446 catchup=false;
447 break;
448
449 default:
450 break;
451 }
452
453
454 while(catchup)
455 {
456 //section id
457 section_id_read=(section_id_read<<8);
458
459 if(!p_getc(&tempbyte,f))
460 {
461 return false;
462 }
463
464 section_id_read+=tempbyte;
465 }
466
467 if(section_id_read==section_id_requested)
468 {
469 return true;
470 }
471 else
472 {
473 //section version info
474 if(!p_igetw(&dummy,f))
475 {
476 return false;
477 }
478
479 if(!p_igetw(&dummy,f))
480 {
481 return false;
482 }
483
484 //section size
485 if(!p_igetl(&section_size,f))
486 {
487 return false;
488 }
489
490 //pack_fseek(f, section_size);
491 while(section_size>65535)
492 {
493 pfread(tempbuf,65535,f);
494 tempbuf[65535]=0;
495 section_size-=65535;
496 }
497
498 if(section_size>0)
499 {
500 pfread(tempbuf,section_size,f);
501 tempbuf[section_size]=0;
502 }
503 }
504
505 //section id
506 if(!p_mgetl(&section_id_read,f))
507 {
508 return false;
509 }
510 }
511
512 return false;
513 }
514
515
516
517
518
519 bool valid_zqt(PACKFILE *f)
520 {
521
522 //word tiles_used;
523 //word combos_used;
524 //open the file
525 //PACKFILE *f = pack_fopen(path, F_READ_PACKED);
526 if(!f)
527 return false;
528
529 //for now, everything else is valid
530 return true;
531
532 /*int16_t version;
533 byte build;
534
535 //read the version and make sure it worked
536 if(!p_igetw(&version,f))
537 {
538 goto error;
539 }
540
541 //read the build and make sure it worked
542 if(!p_getc(&build,f))
543 goto error;
544
545 //read the tile info and make sure it worked
546 if(!p_igetw(&tiles_used,f))
547 {
548 goto error;
549 }
550
551 for (int32_t i=0; i<tiles_used; i++)
552 {
553 if(!pfread(trashbuf,tilesize(tf4Bit),f))
554 {
555 goto error;
556 }
557 }
558
559 //read the combo info and make sure it worked
560 if(!p_igetw(&combos_used,f))
561 {
562 goto error;
563 }
564 for (int32_t i=0; i<combos_used; i++)
565 {
566 if(!pfread(trashbuf,sizeof(newcombo),f))
567 {
568 goto error;
569 }
570 }
571
572 //read the palette info and make sure it worked
573 for (int32_t i=0; i<48; i++)
574 {
575 if(!pfread(trashbuf,newpdTOTAL,f))
576 {
577 goto error;
578 }
579 }
580 if(!pfread(trashbuf,sizeof(palcycle)*256*3,f))
581 {
582 goto error;
583 }
584 for (int32_t i=0; i<MAXLEVELS; i++)
585 {
586 if(!pfread(trashbuf,PALNAMESIZE,f))
587 {
588 goto error;
589 }
590 }
591
592 //read the sprite info and make sure it worked
593 for (int32_t i=0; i<MAXITEMS; i++)
594 {
595 if(!pfread(trashbuf,sizeof(itemdata),f))
596 {
597 goto error;
598 }
599 }
600
601 for (int32_t i=0; i<MAXWPNS; i++)
602 {
603 if(!pfread(trashbuf,sizeof(wpndata),f))
604 {
605 goto error;
606 }
607 }
608
609 //read the triforce pieces info and make sure it worked
610 for (int32_t i=0; i<8; ++i)
611 {
612 if(!p_getc(&trashbuf,f))
613 {
614 goto error;
615 }
616 }
617
618
619
620 //read the game icons info and make sure it worked
621 for (int32_t i=0; i<4; ++i)
622 {
623 if(!p_igetw(&trashbuf,f))
624 {
625 goto error;
626 }
627 }
628
629 //read the misc colors info and map styles info and make sure it worked
630 if(!pfread(trashbuf,sizeof(zcolors),f))
631 {
632 goto error;
633 }
634
635 //read the template screens and make sure it worked
636 byte num_maps;
637 if(!p_getc(&num_maps,f))
638 {
639 goto error;
640 }
641 for (int32_t i=0; i<TEMPLATES; i++)
642 {
643 if(!pfread(trashbuf,sizeof(mapscr),f))
644 {
645 goto error;
646 }
647 }
648 if (num_maps>1) //dungeon templates
649 {
650 for (int32_t i=0; i<TEMPLATES; i++)
651 {
652 if(!pfread(trashbuf,sizeof(mapscr),f))
653 {
654 goto error;
655 }
656 }
657 }
658
659 //yay! it worked! close the file and say everything was ok.
660 pack_fclose(f);
661 return true;
662
663 error:
664 pack_fclose(f);
665 return false;*/
666 }
667
668 bool valid_zqt(const char *filename)
669 {
670 PACKFILE *f=NULL;
671 bool isvalid;
672 int32_t error;
673 f=open_quest_file(&error, filename, false);
674
675 if(!f)
676 {
677 // setPackfilePassword(NULL);
678 return false;
679 }
680
681 isvalid=valid_zqt(f);
682
683 clear_quest_tmpfile();
684 pack_fclose(f);
685
686 // setPackfilePassword(NULL);
687 return isvalid;
688 }
689
690 46 static std::string tmp_file_name;
691 258 void clear_quest_tmpfile()
692 {
693
1/2
✓ Branch 0 taken 258 times.
✗ Branch 1 not taken.
258 if(tmp_file_name.size())
694 {
695 if(exists(tmp_file_name.c_str()))
696 delete_file(tmp_file_name.c_str());
697 tmp_file_name.clear();
698 }
699 258 }
700 /*
701 .qst file history
702
703 .qst files have always been compressed using allegro's packfiles.
704
705 At some point, an encoding layer was added. The two layers look like this:
706
707 1) The top layer is from us. See decode_file_007.
708 [0-24] Preamble "Zelda Classic Quest File"
709 [25-28] Initial decoding seed value.
710 [29-X] Allegro-encoded payload (AKA "packed" file)
711 [last 4] Checksum
712
713 2) The bottom layer is a "compressed packed file" from Allegro 4. The entire payload
714 is XOR'd with a password (datapwd). Once that is undone, the first four bytes are "slh!",
715 followed by a lzss compressed representation of the payload (from allergo' packfile compression).
716 The oldest quests skip the password part.
717
718 Simply, the job of this function is to peel away the top layer.
719
720 With this second layer of encryption, the data isn't any more secure, and adds a significant delay
721 in opening and saving files. There is no version field, so they decryption key is
722 found via trial-by-error (very slow!)
723
724 There are other file types of interest:
725 - .zqt: quest template files, skips top-layer encryption pass
726 - .qsu: "unencoded" (and uncompressed) files; skips encryption and compression (also makes the longtan password moot)
727 - .qu?: same as above. automated backup files
728 - .qb?: same as above. automated backup files
729 - .qt?: compressed and encrypted (or not encrypted, as of May 2023)
730
731 May 2023: .qst files are now saved without the top layer encoding, and no allegro packfile password. The first bytes of these
732 files are now "slh!.AG ZC Enhanced Quest File".
733 The following command will take an existing qst file and upgrade it: `./zquest -unencrypt-qst <input> <output>`
734 */
735 129 PACKFILE *open_quest_file(int32_t *open_error, const char *filename, bool show_progress)
736 {
737
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if (show_progress)
738 {
739 box_start(1, "Loading Quest", get_zc_font(font_lfont), font, true);
740 }
741
742 #ifdef __EMSCRIPTEN__
743 if (em_is_lazy_file(filename))
744 {
745 em_fetch_file(filename);
746 }
747 #endif
748 129 clear_quest_tmpfile();
749 // Note: although this is primarily for loading .qst files, it can also handle all of the
750 // file types mentioned in the comment above. No need to be told if the file being loaded
751 // is encrypted or compressed, we can do some simple and fast checks to determine how to load it.
752 129 bool top_layer_compressed = false;
753 129 bool compressed = false;
754 129 bool encrypted = false;
755
756 // Input files may or may not include a top layer, which may or may not be compressed.
757 // Additionally, the bottom layer may or may not be compressed, and may or may not be encoded
758 // with an allegro packfile password (longtan).
759 // We peek into this file to read the header - we'll either see the top layer's header (ENC_STR)
760 // or the bottom layer's header (QH_IDSTR or QH_NEWIDSTR).
761 // Newly saved .qst files enjoy a fast path here, where there is no top layer at all.
762
763 129 bool id_came_from_compressed_file = false;
764 129 const char* packfile_password = "";
765 char id[32];
766 129 id[0] = id[31] = '\0';
767 129 PACKFILE* pf = pack_fopen_password(filename, F_READ_PACKED, "");
768
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 3 times.
129 if (!pf)
769 3 pf = pack_fopen_password(filename, F_READ_PACKED, packfile_password = datapwd);
770
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 3 times.
129 if (pf)
771 {
772 126 id_came_from_compressed_file = true;
773
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if (!pack_fread(id, sizeof(id)-1, pf))
774 {
775 pack_fclose(pf);
776 Z_message("Unable to read header string\n");
777 return nullptr;
778 }
779 126 pack_fclose(pf);
780 126 }
781 else
782 {
783 3 FILE* f = fopen(filename, "rb");
784
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (!f)
785 {
786 *open_error=qe_notfound;
787 return nullptr;
788 }
789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (!fread(id, sizeof(char), sizeof(id)-1, f))
790 {
791 fclose(f);
792 Z_message("Unable to read header string\n");
793 return nullptr;
794 }
795 3 fclose(f);
796 }
797
798
4/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 122 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 3 times.
129 if (strstr(id, QH_NEWIDSTR) || strstr(id, QH_IDSTR))
799 {
800 // The given file is already just the bottom layer - nothing more to do.
801 // There's no way to rewind a packfile, so just open it again.
802
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if (id_came_from_compressed_file)
803 {
804 126 return pack_fopen_password(filename, F_READ_PACKED, packfile_password);
805 }
806 else
807 {
808 return pack_fopen_password(filename, F_READ, "");
809 }
810 }
811
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 else if (strstr(id, ENC_STR))
812 {
813 3 top_layer_compressed = id_came_from_compressed_file;
814 3 compressed = true;
815 3 encrypted = true;
816 3 }
817 else if (id_came_from_compressed_file && strstr(id, "slh!\xff"))
818 {
819 // We must be reading the compressed contents of an allegro dataobject file. ex: `classic_qst.dat#NESQST_NEW_QST`.
820 // Let's extract the content and re-open as a separate file, so allegro will uncompress correctly.
821
822 char tmpfilename[L_tmpnam];
823 std::tmpnam(tmpfilename);
824 FILE* tf = fopen(tmpfilename, "wb");
825 PACKFILE* pf = pack_fopen_password(filename, F_READ_PACKED, packfile_password);
826
827 int c;
828 while ((c = pack_getc(pf)) != EOF)
829 {
830 fputc(c, tf);
831 }
832 fclose(tf);
833 pack_fclose(pf);
834
835 tmp_file_name = tmpfilename; //store so it can be cleaned up later
836
837 // not good: temp file storage leak. Callers don't know to delete temp files anymore.
838 // We should put qsu in the dat file, or use a separate .qst file for new qst.
839 return pack_fopen_password(tmpfilename, F_READ_PACKED, "");
840 }
841 else
842 {
843 // Unexpected, this is going to fail some header check later.
844 }
845
846 // Everything below here is legacy code - recently saved quest files will have
847 // returned by now.
848
849 char tmpfilename[L_tmpnam];
850 3 temp_name(tmpfilename);
851 char percent_done[30];
852 3 int32_t current_method=0;
853
854 PACKFILE *f;
855 3 const char *passwd= encrypted ? datapwd : "";
856
857 // oldquest flag is set when an unencrypted qst file is suspected.
858 3 bool oldquest = false;
859 int32_t ret;
860
861
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(strcmp(filename, "default.qst")!=0)
862 {
863 3 box_out(filename);
864 3 }
865 else
866 {
867 box_out("new quest"); // Or whatever
868 }
869 3 box_out("...");
870 3 box_eol();
871 3 box_eol();
872
873
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(encrypted)
874 {
875 3 box_out("Decrypting...");
876 3 box_save_x();
877 3 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_MAX-1, top_layer_compressed, passwd);
878
879
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(ret)
880 {
881 switch(ret)
882 {
883 case 1:
884 box_out("error.");
885 box_eol();
886 box_end(true);
887 *open_error=qe_notfound;
888 return NULL;
889
890 case 2:
891 box_out("error.");
892 box_eol();
893 box_end(true);
894 *open_error=qe_internal;
895 return NULL;
896 // be sure not to delete tmpfilename now...
897 }
898
899 if(ret==5) //old encryption?
900 {
901 current_method++;
902 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
903 box_out(percent_done);
904 box_load_x();
905 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_211B9, strstr(filename, ".dat#")!=NULL, passwd);
906 }
907
908 if(ret==5) //old encryption?
909 {
910 current_method++;
911 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
912 box_out(percent_done);
913 box_load_x();
914 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B185, strstr(filename, ".dat#")!=NULL, passwd);
915 }
916
917 if(ret==5) //old encryption?
918 {
919 current_method++;
920 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
921 box_out(percent_done);
922 box_load_x();
923 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B105, strstr(filename, ".dat#")!=NULL, passwd);
924 }
925
926 if(ret==5) //old encryption?
927 {
928 current_method++;
929 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
930 box_out(percent_done);
931 box_load_x();
932 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B104, strstr(filename, ".dat#")!=NULL, passwd);
933 }
934
935 if(ret)
936 {
937 oldquest = true;
938 passwd="";
939 }
940 }
941
942 3 box_out("okay.");
943 3 box_eol();
944 3 }
945 else
946 {
947 oldquest = true;
948 }
949
950 3 box_out("Opening...");
951
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 f = pack_fopen_password(oldquest ? filename : tmpfilename, compressed ? F_READ_PACKED : F_READ, passwd);
952
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!f)
953 {
954 if((compressed==1)&&(errno==EDOM))
955 {
956 f = pack_fopen_password(oldquest ? filename : tmpfilename, F_READ, passwd);
957 }
958
959 if(!f)
960 {
961 if(!oldquest)
962 {
963 delete_file(tmpfilename);
964 }
965 box_out("error.");
966 box_eol();
967 box_end(true);
968 *open_error=qe_invalid;
969 return NULL;
970 }
971 }
972
973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(!oldquest)
974 {
975 3 delete_file(tmpfilename);
976 3 }
977
978 3 box_out("okay.");
979 3 box_eol();
980
981 3 return f;
982 129 }
983
984 PACKFILE *open_quest_template(zquestheader *Header, char *deletefilename, bool validate)
985 {
986 char *filename;
987 PACKFILE *f=NULL;
988 int32_t open_error=0;
989
990 strcpy(qstdat_string, "modules/classic/default.qst");
991 if(Header->templatepath[0]==0)
992 {
993 filename=(char *)malloc(2048);
994 strcpy(filename, qstdat_string);
995 }
996 else
997 {
998 // TODO: should be safe to remove this, no one seems to use custom quest templates.
999 filename=Header->templatepath;
1000 }
1001
1002 f=open_quest_file(&open_error, filename, false);
1003
1004 if(Header->templatepath[0]==0)
1005 {
1006 free(filename);
1007 }
1008
1009 if(!f)
1010 {
1011 return NULL;
1012 }
1013
1014 if(validate)
1015 {
1016 if(!valid_zqt(f))
1017 {
1018 jwin_alert("Error","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
1019 pack_fclose(f);
1020 clear_quest_tmpfile();
1021 return NULL;
1022 }
1023 }
1024
1025 return f;
1026 }
1027
1028 bool init_section(zquestheader *Header, int32_t section_id, miscQdata *Misc, zctune *tunes, bool validate)
1029 {
1030 // We absolutely do not support loading from a template file to initialize data outside the editor.
1031 // TODO: move this code into zq/
1032 if (get_app_id() != App::zquest) return false;
1033
1034 combosread=false;
1035 mapsread=false;
1036 fixffcs=false;
1037
1038 switch(section_id)
1039 {
1040 case ID_RULES:
1041 case ID_STRINGS:
1042 case ID_MISC:
1043 case ID_TILES:
1044 case ID_COMBOS:
1045 case ID_CSETS:
1046 case ID_MAPS:
1047 case ID_DMAPS:
1048 case ID_DOORS:
1049 case ID_ITEMS:
1050 case ID_WEAPONS:
1051 case ID_COLORS:
1052 case ID_ICONS:
1053 case ID_INITDATA:
1054 case ID_GUYS:
1055 case ID_MIDIS:
1056 case ID_CHEATS:
1057 case ID_ITEMDROPSETS:
1058 case ID_FAVORITES:
1059 break;
1060
1061 default:
1062 return false;
1063 break;
1064 }
1065
1066 int32_t ret;
1067 word version, build;
1068 PACKFILE *f=NULL;
1069
1070 char deletefilename[1024];
1071 deletefilename[0]=0;
1072
1073 //why is this here?
1074 /*
1075 if(colordata==NULL)
1076 return false;
1077 */
1078
1079 //setPackfilePassword(datapwd);
1080 f=open_quest_template(Header, deletefilename, validate);
1081
1082 if(!f) //no file, nothing to delete
1083 {
1084 // setPackfilePassword(NULL);
1085 return false;
1086 }
1087
1088 ret=get_version_and_build(f, &version, &build);
1089
1090 if(ret||(version==0))
1091 {
1092 pack_fclose(f);
1093 clear_quest_tmpfile();
1094
1095 if(deletefilename[0])
1096 {
1097 delete_file(deletefilename);
1098 }
1099
1100 // setPackfilePassword(NULL);
1101 return false;
1102 }
1103
1104 if(!find_section(f, section_id))
1105 {
1106 al_trace("Can't find section!\n");
1107 pack_fclose(f);
1108 clear_quest_tmpfile();
1109
1110 if(deletefilename[0])
1111 {
1112 delete_file(deletefilename);
1113 }
1114
1115 //setPackfilePassword(NULL);
1116 return false;
1117 }
1118
1119 switch(section_id)
1120 {
1121 case ID_RULES:
1122 //rules
1123 ret=readrules(f, Header);
1124 break;
1125
1126 case ID_STRINGS:
1127 //strings
1128 ret=readstrings(f, Header);
1129 break;
1130
1131 case ID_MISC:
1132 //misc data
1133 ret=readmisc(f, Header, Misc);
1134 break;
1135
1136 case ID_TILES:
1137 //tiles
1138 ret=readtiles(f, newtilebuf, Header, version, build, 0, NEWMAXTILES, true);
1139 break;
1140
1141 case ID_COMBOS:
1142 //combos
1143 clear_combos();
1144 ret=readcombos(f, Header, version, build, 0, MAXCOMBOS);
1145 combosread=true;
1146 break;
1147
1148 case ID_COMBOALIASES:
1149 //combos
1150 ret=readcomboaliases(f, Header, version, build);
1151 break;
1152
1153 case ID_CSETS:
1154 //color data
1155 ret=readcolordata(f, Misc, version, build, 0, newerpdTOTAL);
1156 break;
1157
1158 case ID_MAPS:
1159 //maps
1160 ret=readmaps(f, Header);
1161 mapsread=true;
1162 break;
1163
1164 case ID_DMAPS:
1165 //dmaps
1166 ret=readdmaps(f, Header, version, build, 0, MAXDMAPS);
1167 break;
1168
1169 case ID_DOORS:
1170 //door combo sets
1171 ret=readdoorcombosets(f, Header);
1172 break;
1173
1174 case ID_ITEMS:
1175 //items
1176 ret=readitems(f, version, build);
1177 break;
1178
1179 case ID_WEAPONS:
1180 //weapons
1181 ret=readweapons(f, Header);
1182 break;
1183
1184 case ID_COLORS:
1185 //misc. colors
1186 ret=readmisccolors(f, Header, Misc);
1187 break;
1188
1189 case ID_ICONS:
1190 //game icons
1191 ret=readgameicons(f, Header, Misc);
1192 break;
1193
1194 case ID_INITDATA:
1195 //initialization data
1196 ret=readinitdata(f, Header);
1197 break;
1198
1199 case ID_GUYS:
1200 //guys
1201 ret=readguys(f, Header);
1202 break;
1203
1204 case ID_MIDIS:
1205 //midis
1206 ret=readtunes(f, Header, tunes);
1207 break;
1208
1209 case ID_CHEATS:
1210 //cheat codes
1211 ret=readcheatcodes(f, Header);
1212 break;
1213
1214 case ID_ITEMDROPSETS:
1215 //item drop sets
1216 // Why is this one commented out?
1217 //ret=readitemdropsets(f, (int32_t)version, (word)build);
1218 break;
1219
1220 case ID_FAVORITES:
1221 // favorite combos and aliases
1222 ret=readfavorites(f, version, build);
1223 break;
1224
1225 default:
1226 ret=-1;
1227 break;
1228 }
1229
1230 pack_fclose(f);
1231 clear_quest_tmpfile();
1232
1233 if(deletefilename[0])
1234 {
1235 delete_file(deletefilename);
1236 }
1237
1238 //setPackfilePassword(NULL);
1239 if(!ret)
1240 {
1241 return true;
1242 }
1243
1244 return false;
1245 }
1246
1247 bool init_tiles(bool validate, zquestheader *Header)
1248 {
1249 return init_section(Header, ID_TILES, NULL, NULL, validate);
1250 }
1251
1252 bool init_combos(bool validate, zquestheader *Header)
1253 {
1254 return init_section(Header, ID_COMBOS, NULL, NULL, validate);
1255 }
1256
1257 bool init_colordata(bool validate, zquestheader *Header, miscQdata *Misc)
1258 {
1259 return init_section(Header, ID_CSETS, Misc, NULL, validate);
1260 }
1261
1262 129 void init_spritelists()
1263 {
1264
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 36 times.
129 if(FFCore.quest_format[vZelda] < 0x255)
1265 {
1266 93 guys.setMax(255);
1267 93 items.setMax(255);
1268 93 Ewpns.setMax(255);
1269 93 Lwpns.setMax(255);
1270 93 Sitems.setMax(255);
1271 93 chainlinks.setMax(255);
1272 93 decorations.setMax(255);
1273 93 particles.setMax(255);
1274 93 }
1275 else
1276 {
1277 36 guys.setMax(255);
1278 36 items.setMax(255);
1279 36 Ewpns.setMax(255);
1280 36 Lwpns.setMax(255);
1281 36 Sitems.setMax(255);
1282 36 chainlinks.setMax(255);
1283 36 decorations.setMax(255);
1284 36 particles.setMax(255*((255*4)+1)); //255 per sprite that can use particles; guys, items, ewpns, lwpns, +HERO
1285 }
1286 129 }
1287
1288 46 bool reset_items(bool validate, zquestheader *Header)
1289 {
1290 46 bool ret = true;
1291
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if (get_app_id() == App::zquest)
1292 ret = init_section(Header, ID_ITEMS, NULL, NULL, validate);
1293
1294
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 11776 times.
11822 for(int32_t i=0; i<MAXITEMS; i++) reset_itemname(i);
1295
1296 46 return ret;
1297 }
1298
1299 bool reset_guys()
1300 {
1301 // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
1302 init_guys(V_GUYS);
1303 return true;
1304 }
1305
1306 bool reset_wpns(bool validate, zquestheader *Header)
1307 {
1308 bool ret = true;
1309 if (get_app_id() == App::zquest)
1310 ret = init_section(Header, ID_WEAPONS, NULL, NULL, validate);
1311
1312 for(int32_t i=0; i<MAXWPNS; i++)
1313 reset_weaponname(i);
1314
1315 return ret;
1316 }
1317
1318 bool reset_mapstyles(bool validate, miscQdata *Misc)
1319 {
1320 Misc->colors.blueframe_tile = 20044;
1321 Misc->colors.blueframe_cset = 0;
1322 Misc->colors.triforce_tile = 23461;
1323 Misc->colors.triforce_cset = 1;
1324 Misc->colors.triframe_tile = 18752;
1325 Misc->colors.triframe_cset = 1;
1326 Misc->colors.overworld_map_tile = 16990;
1327 Misc->colors.overworld_map_cset = 2;
1328 Misc->colors.HCpieces_tile = 21160;
1329 Misc->colors.HCpieces_cset = 8;
1330 Misc->colors.dungeon_map_tile = 19651;
1331 Misc->colors.dungeon_map_cset = 8;
1332 return true;
1333 }
1334
1335 46 int32_t get_qst_buffers()
1336 {
1337 46 memrequested+=(sizeof(mapscr)*MAPSCRS);
1338 46 Z_message("Allocating map buffer (%s)... ", byte_conversion2(sizeof(mapscr)*MAPSCRS,memrequested,-1, -1));
1339 46 TheMaps.resize(MAPSCRS);
1340 46 map_autolayers.resize(6);
1341
1342
2/2
✓ Branch 0 taken 6256 times.
✓ Branch 1 taken 46 times.
6302 for(int32_t i(0); i<MAPSCRS; i++)
1343 6256 TheMaps[i].zero_memory();
1344
1345 //memset(TheMaps, 0, sizeof(mapscr)*MAPSCRS); //shouldn't need this anymore
1346 46 Z_message("OK\n"); // Allocating map buffer...
1347
1348 46 memrequested+=(sizeof(zcmap)*MAXMAPS2);
1349 46 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(zcmap)*MAXMAPS2,memrequested,-1,-1));
1350
1351
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if((ZCMaps=(zcmap*)malloc(sizeof(zcmap)*MAXMAPS2))==NULL)
1352 return 0;
1353
1354 46 Z_message("OK\n");
1355
1356 // Allocating space for all 65535 strings uses up 10.62MB...
1357 // The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
1358 // (Shoelace's "Hero of Dreams" uses 1415.)
1359 // So let's be a bit generous and allow 4096 initially.
1360 // In the rare event that a quest overshoots this mark, we'll reallocate to the full 65535 later.
1361 // I tested it and it worked without flaw on 6/6/11. - L.
1362 // 2022: bumped from 4096 to 8192 to avoid a bug where the Strings menu shows (None) strings when the list passes
1363 // this threshold. Possibly some bug related to `msglistcache` to being reset?
1364 // See https://discord.com/channels/876899628556091432/992984989073416242
1365 46 msg_strings_size = 8192;
1366 46 memrequested+=(sizeof(MsgStr)*msg_strings_size);
1367 46 Z_message("Allocating string buffer (%s)... ", byte_conversion2(sizeof(MsgStr)*msg_strings_size,memrequested,-1,-1));
1368
1369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
46 MsgStrings = new MsgStr[msg_strings_size];
1370
1371 //memset(MsgStrings, 0, sizeof(MsgStr)*msg_strings_size);
1372
2/2
✓ Branch 0 taken 376832 times.
✓ Branch 1 taken 46 times.
376878 for(auto q = 0; q < msg_strings_size; ++q)
1373 {
1374 376832 MsgStrings[q].clear();
1375 376832 }
1376 46 Z_message("OK\n"); // Allocating string buffer...
1377
1378 46 memrequested+=(sizeof(DoorComboSet)*MAXDOORCOMBOSETS);
1379 46 Z_message("Allocating door combo buffer (%s)... ", byte_conversion2(sizeof(DoorComboSet)*MAXDOORCOMBOSETS,memrequested,-1,-1));
1380
1381
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if((DoorComboSets=(DoorComboSet*)malloc(sizeof(DoorComboSet)*MAXDOORCOMBOSETS))==NULL)
1382 return 0;
1383
1384 46 Z_message("OK\n"); // Allocating door combo buffer...
1385
1386 46 memrequested+=(sizeof(dmap)*MAXDMAPS);
1387 46 Z_message("Allocating dmap buffer (%s)... ", byte_conversion2(sizeof(dmap)*MAXDMAPS,memrequested,-1,-1));
1388
1389
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if((DMaps=(dmap*)malloc(sizeof(dmap)*MAXDMAPS))==NULL)
1390 return 0;
1391
1392 46 memset(DMaps, 0, sizeof(dmap)*MAXDMAPS);
1393 46 Z_message("OK\n"); // Allocating dmap buffer...
1394
1395 46 memrequested+=(sizeof(newcombo)*MAXCOMBOS);
1396 46 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(newcombo)*MAXCOMBOS,memrequested,-1,-1));
1397
1398 46 combobuf.clear();
1399 46 combobuf.resize(MAXCOMBOS);
1400 46 Z_message("OK\n"); // Allocating combo buffer...
1401
1402 46 memrequested+=(psTOTAL255);
1403 46 Z_message("Allocating color data buffer (%s)... ", byte_conversion2(psTOTAL255,memrequested,-1,-1));
1404
1405
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if((colordata=(byte*)malloc(psTOTAL255))==NULL)
1406 return 0;
1407
1408 46 Z_message("OK\n"); // Allocating color data buffer...
1409
1410 46 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1411 46 Z_message("Allocating tile buffer (%s)... ", byte_conversion2(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)),memrequested,-1,-1));
1412
1413 46 free_newtilebuf();
1414
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1415 return 0;
1416
1417 46 memset(newtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1418 //Z_message("Performed memset on tiles\n");
1419 46 clear_tiles(newtilebuf);
1420 //Z_message("Performed clear_tiles()\n");
1421 46 Z_message("OK\n"); // Allocating tile buffer...
1422
1423
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if(is_zquest())
1424 {
1425 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1426 Z_message("Allocating tile grab buffer (%s)... ", byte_conversion2(NEWMAXTILES*sizeof(tiledata),memrequested,-1,-1));
1427
1428 if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1429 return 0;
1430
1431 memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1432 clear_tiles(grabtilebuf);
1433 Z_message("OK\n"); // Allocating tile grab buffer...
1434 }
1435
1436 46 memrequested+=(100000);
1437 46 Z_message("Allocating trash buffer (%s)... ", byte_conversion2(100000,memrequested,-1,-1));
1438
1439
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if((trashbuf=(byte*)malloc(100000))==NULL)
1440 return 0;
1441
1442 46 Z_message("OK\n"); // Allocating trash buffer...
1443
1444 // Big, ugly band-aid here. Perhaps the most common cause of random crashes
1445 // has been inadvertently accessing itemsbuf[-1]. All such crashes should be
1446 // fixed by ensuring there's actually itemdata there.
1447 // If you change this, be sure to update del_qst_buffers, too.
1448
1449 46 memrequested+=(sizeof(itemdata)*(MAXITEMS+1));
1450 46 Z_message("Allocating item buffer (%s)... ", byte_conversion2(sizeof(itemdata)*(MAXITEMS+1),memrequested,-1,-1));
1451
1452
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
1453 return 0;
1454
1455 46 memset(itemsbuf,0,sizeof(itemdata)*(MAXITEMS+1));
1456 46 itemsbuf++;
1457 46 Z_message("OK\n"); // Allocating item buffer...
1458
1459 46 memrequested+=(sizeof(wpndata)*MAXWPNS);
1460 46 Z_message("Allocating weapon buffer (%s)... ", byte_conversion2(sizeof(wpndata)*MAXWPNS,memrequested,-1,-1));
1461
1462
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
1463 return 0;
1464
1465 46 memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
1466 46 Z_message("OK\n"); // Allocating weapon buffer...
1467
1468 46 memrequested+=(sizeof(guydata)*MAXGUYS);
1469 46 Z_message("Allocating guy buffer (%s)... ", byte_conversion2(sizeof(guydata)*MAXGUYS,memrequested,-1,-1));
1470
1471
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
1472 return 0;
1473
1474 46 memset(guysbuf,0,sizeof(guydata)*MAXGUYS);
1475 46 Z_message("OK\n"); // Allocating guy buffer...
1476
1477 46 memrequested+=(sizeof(comboclass)*cMAX);
1478 46 Z_message("Allocating combo class buffer (%s)... ", byte_conversion2(sizeof(comboclass)*cMAX,memrequested,-1,-1));
1479
1480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
46 if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
1481 return 0;
1482
1483 46 Z_message("OK\n"); // Allocating combo class buffer...
1484
1485 46 return 1;
1486 46 }
1487
1488
1489 46 void free_newtilebuf()
1490 {
1491
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
46 if(newtilebuf)
1492 {
1493 for(int32_t i=0; i<NEWMAXTILES; i++)
1494 if(newtilebuf[i].data)
1495 free(newtilebuf[i].data);
1496
1497 free(newtilebuf);
1498 newtilebuf = 0;
1499 }
1500 46 }
1501
1502 void free_grabtilebuf()
1503 {
1504 if(is_zquest())
1505 {
1506 if(grabtilebuf)
1507 {
1508 for(int32_t i=0; i<NEWMAXTILES; i++)
1509 if(grabtilebuf[i].data) free(grabtilebuf[i].data);
1510
1511 free(grabtilebuf);
1512 grabtilebuf = 0;
1513 }
1514 }
1515 }
1516
1517 void del_qst_buffers()
1518 {
1519 al_trace("Cleaning maps. \n");
1520
1521 if(ZCMaps) free(ZCMaps);
1522
1523 if(MsgStrings) delete[] MsgStrings;
1524
1525 if(DoorComboSets) free(DoorComboSets);
1526
1527 if(DMaps) free(DMaps);
1528
1529 combobuf.clear();
1530
1531 if(colordata) free(colordata);
1532
1533 al_trace("Cleaning tile buffers. \n");
1534 free_newtilebuf();
1535 free_grabtilebuf();
1536
1537 al_trace("Cleaning misc. \n");
1538
1539 if(trashbuf) free(trashbuf);
1540
1541 // See get_qst_buffers
1542 if(itemsbuf)
1543 {
1544 itemsbuf--;
1545 free(itemsbuf);
1546 }
1547
1548 if(wpnsbuf) free(wpnsbuf);
1549
1550 if(guysbuf) free(guysbuf);
1551
1552 if(combo_class_buf) free(combo_class_buf);
1553 }
1554
1555 4 bool init_palnames()
1556 {
1557 // if(palnames==NULL)
1558 // return false;
1559
1560
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 4 times.
2052 for(int32_t x=0; x<MAXLEVELS; x++)
1561 {
1562
4/4
✓ Branch 0 taken 2036 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 4 times.
2048 switch(x)
1563 {
1564 case 0:
1565 4 sprintf(palnames[x],"Overworld");
1566 4 break;
1567
1568 case 10:
1569 4 sprintf(palnames[x],"Caves");
1570 4 break;
1571
1572 case 11:
1573 4 sprintf(palnames[x],"Passageways");
1574 4 break;
1575
1576 default:
1577 2036 sprintf(palnames[x],"%c",0);
1578 2036 break;
1579 }
1580 2048 }
1581
1582 4 return true;
1583 }
1584
1585 25210 static void *read_block(PACKFILE *f, int32_t size, int32_t alloc_size)
1586 {
1587 void *p;
1588
1589
1/2
✓ Branch 0 taken 25210 times.
✗ Branch 1 not taken.
25210 p = _AL_MALLOC(MAX(size, alloc_size));
1590
1591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25210 times.
25210 if(!p)
1592 {
1593 return NULL;
1594 }
1595
1596
1/2
✓ Branch 0 taken 25210 times.
✗ Branch 1 not taken.
25210 if(!pfread(p,size,f))
1597 {
1598 _AL_FREE(p);
1599 return NULL;
1600 }
1601
1602
1/2
✓ Branch 0 taken 25210 times.
✗ Branch 1 not taken.
25210 if(pack_ferror(f))
1603 {
1604 _AL_FREE(p);
1605 return NULL;
1606 }
1607
1608 25210 return p;
1609 25210 }
1610
1611 /* read_midi:
1612 * Reads MIDI data from a datafile (this is not the same thing as the
1613 * standard midi file format).
1614 */
1615
1616 2302 static MIDI *read_midi(PACKFILE *f)
1617 {
1618 MIDI *m;
1619 int32_t c;
1620 2302 int16_t divisions=0;
1621 2302 int32_t len=0;
1622
1623 2302 m = (MIDI*)_AL_MALLOC(sizeof(MIDI));
1624
1625
1/2
✓ Branch 0 taken 2302 times.
✗ Branch 1 not taken.
2302 if(!m)
1626 {
1627 return NULL;
1628 }
1629
1630
2/2
✓ Branch 0 taken 73664 times.
✓ Branch 1 taken 2302 times.
75966 for(c=0; c<MIDI_TRACKS; c++)
1631 {
1632 73664 m->track[c].len = 0;
1633 73664 m->track[c].data = NULL;
1634 73664 }
1635
1636 2302 p_mgetw(&divisions,f);
1637 2302 m->divisions=divisions;
1638
1639
2/2
✓ Branch 0 taken 73664 times.
✓ Branch 1 taken 2302 times.
75966 for(c=0; c<MIDI_TRACKS; c++)
1640 {
1641 73664 p_mgetl(&len,f);
1642 73664 m->track[c].len=len;
1643
1644
2/2
✓ Branch 0 taken 48454 times.
✓ Branch 1 taken 25210 times.
73664 if(m->track[c].len > 0)
1645 {
1646 25210 m->track[c].data = (byte*)read_block(f, m->track[c].len, 0);
1647
1648
1/2
✓ Branch 0 taken 25210 times.
✗ Branch 1 not taken.
25210 if(!m->track[c].data)
1649 {
1650 destroy_midi(m);
1651 return NULL;
1652 }
1653 25210 }
1654 73664 }
1655
1656 LOCK_DATA(m, sizeof(MIDI));
1657
1658
2/2
✓ Branch 0 taken 73664 times.
✓ Branch 1 taken 2302 times.
75966 for(c=0; c<MIDI_TRACKS; c++)
1659 {
1660
2/2
✓ Branch 0 taken 25210 times.
✓ Branch 1 taken 48454 times.
73664 if(m->track[c].data)
1661 {
1662 LOCK_DATA(m->track[c].data, m->track[c].len);
1663 25210 }
1664 73664 }
1665
1666 2302 return m;
1667 2302 }
1668
1669 void clear_combo(int32_t i)
1670 {
1671 combobuf[i].clear();
1672 }
1673
1674 void clear_combos()
1675 {
1676 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
1677 clear_combo(tmpcounter);
1678 }
1679
1680 void pack_combos()
1681 {
1682 int32_t di = 0;
1683
1684 for(int32_t si=0; si<1024; si+=2)
1685 combobuf[di++] = combobuf[si];
1686
1687 for(; di<1024; di++)
1688 clear_combo(di);
1689 }
1690
1691 129 void reset_tunes(zctune *tune)
1692 {
1693
2/2
✓ Branch 0 taken 32508 times.
✓ Branch 1 taken 129 times.
32637 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
1694 {
1695 32508 tune[i].reset();
1696 32508 }
1697 129 }
1698
1699
1700 /*void reset_midi(zcmidi_ *m)
1701 {
1702 m->title[0]=0;
1703 m->loop=1;
1704 m->volume=144;
1705 m->start=0;
1706 m->loop_start=-1;
1707 m->loop_end=-1;
1708 if(m->midi)
1709 {
1710 destroy_midi(m->midi);
1711 }
1712 m->midi=NULL;
1713 }
1714
1715
1716 void reset_midis(zcmidi_ *m)
1717 {
1718 for(int32_t i=0; i<MAXCUSTOMMIDIS; i++)
1719 {
1720 reset_midi(m+i);
1721 }
1722 }
1723 */
1724
1725 void reset_scr(int32_t scr)
1726 {
1727 /*
1728 byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1729 for(unsigned i=0; i<sizeof(mapscr); i++)
1730 *(di++) = 0;
1731 TheMaps[scr].valid=mVERSION;
1732 */
1733
1734 TheMaps[scr].zero_memory();
1735 //byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1736
1737 for(int32_t i=0; i<6; i++)
1738 {
1739 //these will be uncommented later
1740 //TheMaps[scr].layerxsize[i]=16;
1741 //TheMaps[scr].layerysize[i]=11;
1742 TheMaps[scr].layeropacity[i]=255;
1743 }
1744
1745 TheMaps[scr].valid=mVERSION;
1746
1747 }
1748
1749 /* For reference:
1750
1751 enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
1752 qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
1753 */
1754
1755 3582 int32_t operator ==(DoorComboSet a, DoorComboSet b)
1756 {
1757
2/2
✓ Branch 0 taken 16494 times.
✓ Branch 1 taken 1614 times.
18108 for(int32_t i=0; i<9; i++)
1758 {
1759
2/2
✓ Branch 0 taken 89124 times.
✓ Branch 1 taken 14526 times.
103650 for(int32_t j=0; j<6; j++)
1760 {
1761
2/2
✓ Branch 0 taken 29052 times.
✓ Branch 1 taken 60072 times.
89124 if(j<4)
1762 {
1763
2/2
✓ Branch 0 taken 58104 times.
✓ Branch 1 taken 1968 times.
60072 if(a.doorcombo_u[i][j]!=b.doorcombo_u[i][j])
1764 {
1765 1968 return false;
1766 }
1767
1768
1/2
✓ Branch 0 taken 58104 times.
✗ Branch 1 not taken.
58104 if(a.doorcset_u[i][j]!=b.doorcset_u[i][j])
1769 {
1770 return false;
1771 }
1772
1773
1/2
✓ Branch 0 taken 58104 times.
✗ Branch 1 not taken.
58104 if(a.doorcombo_d[i][j]!=b.doorcombo_d[i][j])
1774 {
1775 return false;
1776 }
1777
1778
1/2
✓ Branch 0 taken 58104 times.
✗ Branch 1 not taken.
58104 if(a.doorcset_d[i][j]!=b.doorcset_d[i][j])
1779 {
1780 return false;
1781 }
1782 58104 }
1783
1784
1/2
✓ Branch 0 taken 87156 times.
✗ Branch 1 not taken.
87156 if(a.doorcombo_l[i][j]!=b.doorcombo_l[i][j])
1785 {
1786 return false;
1787 }
1788
1789
1/2
✓ Branch 0 taken 87156 times.
✗ Branch 1 not taken.
87156 if(a.doorcset_l[i][j]!=b.doorcset_l[i][j])
1790 {
1791 return false;
1792 }
1793
1794
1/2
✓ Branch 0 taken 87156 times.
✗ Branch 1 not taken.
87156 if(a.doorcombo_r[i][j]!=b.doorcombo_r[i][j])
1795 {
1796 return false;
1797 }
1798
1799
1/2
✓ Branch 0 taken 87156 times.
✗ Branch 1 not taken.
87156 if(a.doorcset_r[i][j]!=b.doorcset_r[i][j])
1800 {
1801 return false;
1802 }
1803 87156 }
1804
1805
2/2
✓ Branch 0 taken 11298 times.
✓ Branch 1 taken 3228 times.
14526 if(i<2)
1806 {
1807
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.flags[i]!=b.flags[i])
1808 {
1809 return false;
1810 }
1811
1812
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.bombdoorcombo_u[i]!=b.bombdoorcombo_u[i])
1813 {
1814 return false;
1815 }
1816
1817
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.bombdoorcset_u[i]!=b.bombdoorcset_u[i])
1818 {
1819 return false;
1820 }
1821
1822
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.bombdoorcombo_d[i]!=b.bombdoorcombo_d[i])
1823 {
1824 return false;
1825 }
1826
1827
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.bombdoorcset_d[i]!=b.bombdoorcset_d[i])
1828 {
1829 return false;
1830 }
1831 3228 }
1832
1833
2/2
✓ Branch 0 taken 9684 times.
✓ Branch 1 taken 4842 times.
14526 if(i<3)
1834 {
1835
1/2
✓ Branch 0 taken 4842 times.
✗ Branch 1 not taken.
4842 if(a.bombdoorcombo_l[i]!=b.bombdoorcombo_l[i])
1836 {
1837 return false;
1838 }
1839
1840
1/2
✓ Branch 0 taken 4842 times.
✗ Branch 1 not taken.
4842 if(a.bombdoorcset_l[i]!=b.bombdoorcset_l[i])
1841 {
1842 return false;
1843 }
1844
1845
1/2
✓ Branch 0 taken 4842 times.
✗ Branch 1 not taken.
4842 if(a.bombdoorcombo_r[i]!=b.bombdoorcombo_r[i])
1846 {
1847 return false;
1848 }
1849
1850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4842 times.
4842 if(a.bombdoorcset_r[i]!=b.bombdoorcset_r[i])
1851 {
1852 return false;
1853 }
1854 4842 }
1855
1856
1/2
✓ Branch 0 taken 14526 times.
✗ Branch 1 not taken.
14526 if(a.walkthroughcombo[i]!=b.walkthroughcombo[i])
1857 {
1858 return false;
1859 }
1860
1861
1/2
✓ Branch 0 taken 14526 times.
✗ Branch 1 not taken.
14526 if(a.walkthroughcset[i]!=b.walkthroughcset[i])
1862 {
1863 return false;
1864 }
1865 14526 }
1866
1867 1614 return true;
1868 3582 }
1869
1870 int32_t doortranslations_u[9][4]=
1871 {
1872 {37,38,53,54},
1873 {37,38,39,40},
1874 {37,38,55,56},
1875 {37,38,39,40},
1876 {37,38,53,54},
1877 {37,38,53,54},
1878 {37,38,53,54},
1879 {7,8,23,24},
1880 {7,8,41,42}
1881 };
1882
1883 int32_t doortranslations_d[9][4]=
1884 {
1885 {117,118,133,134},
1886 {135,136,133,134},
1887 {119,120,133,134},
1888 {135,136,133,134},
1889 {117,118,133,134},
1890 {117,118,133,134},
1891 {117,118,133,134},
1892 {151,152,167,168},
1893 {137,138,167,168},
1894 };
1895
1896 //enum {dt_pass=0, dt_lock, dt_shut, dt_boss, dt_olck, dt_osht, dt_obos, dt_wall, dt_bomb, dt_walk, dt_max};
1897 int32_t doortranslations_l[9][6]=
1898 {
1899 {66,67,82,83,98,99},
1900 {66,68,82,84,98,100},
1901 {66,69,82,85,98,101},
1902 {66,68,82,84,98,100},
1903 {66,67,82,83,98,99},
1904 {66,67,82,83,98,99},
1905 {66,67,82,83,98,99},
1906 {64,65,80,81,96,97},
1907 {64,65,80,114,96,97},
1908 };
1909
1910 int32_t doortranslations_r[9][6]=
1911 {
1912
1913 {76,77,92,93,108,109},
1914 {75,77,91,93,107,109},
1915 {74,77,90,93,106,109},
1916 {75,77,91,93,107,109},
1917 {76,77,92,93,108,109},
1918 {76,77,92,93,108,109},
1919 {76,77,92,93,108,109},
1920 {78,79,94,95,110,111},
1921 {78,79,125,95,110,111},
1922 };
1923
1924 314668 int32_t tdcmbdat(int32_t map, int32_t scr, int32_t pos)
1925 {
1926 314668 return (TheMaps[map*MAPSCRS+TEMPLATE].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1927 }
1928
1929 308180 int32_t tdcmbcset(int32_t map, int32_t scr, int32_t pos)
1930 {
1931 //these are here to bypass compiler warnings about unused arguments
1932 308180 map=map;
1933 308180 scr=scr;
1934 308180 pos=pos;
1935
1936 //what does this function do?
1937 // return TheMaps[map*MAPSCRS+TEMPLATE].cset[pos];
1938 308180 return 2;
1939 }
1940
1941 7072 int32_t MakeDoors(int32_t map, int32_t scr)
1942 {
1943
2/2
✓ Branch 0 taken 5450 times.
✓ Branch 1 taken 1622 times.
7072 if(!(TheMaps[map*MAPSCRS+scr].valid&mVALID))
1944 {
1945 5450 return 0;
1946 }
1947
1948 DoorComboSet tempdcs;
1949 1622 memset(&tempdcs, 0, sizeof(DoorComboSet));
1950
1951 //up
1952
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1953 {
1954
2/2
✓ Branch 0 taken 58392 times.
✓ Branch 1 taken 14598 times.
72990 for(int32_t j=0; j<4; j++)
1955 {
1956 58392 tempdcs.doorcombo_u[i][j]=tdcmbdat(map,scr,doortranslations_u[i][j]);
1957 58392 tempdcs.doorcset_u[i][j]=tdcmbcset(map,scr,doortranslations_u[i][j]);
1958 58392 }
1959 14598 }
1960
1961 1622 tempdcs.bombdoorcombo_u[0]=tdcmbdat(map,scr,57);
1962 1622 tempdcs.bombdoorcset_u[0]=tdcmbcset(map,scr,57);
1963 1622 tempdcs.bombdoorcombo_u[1]=tdcmbdat(map,scr,58);
1964 1622 tempdcs.bombdoorcset_u[1]=tdcmbcset(map,scr,58);
1965 1622 tempdcs.walkthroughcombo[0]=tdcmbdat(map,scr,34);
1966 1622 tempdcs.walkthroughcset[0]=tdcmbdat(map,scr,34);
1967
1968 //down
1969
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1970 {
1971
2/2
✓ Branch 0 taken 58392 times.
✓ Branch 1 taken 14598 times.
72990 for(int32_t j=0; j<4; j++)
1972 {
1973 58392 tempdcs.doorcombo_d[i][j]=tdcmbdat(map,scr,doortranslations_d[i][j]);
1974 58392 tempdcs.doorcset_d[i][j]=tdcmbcset(map,scr,doortranslations_d[i][j]);
1975 58392 }
1976 14598 }
1977
1978 1622 tempdcs.bombdoorcombo_d[0]=tdcmbdat(map,scr,121);
1979
1980 1622 tempdcs.bombdoorcset_d[0]=tdcmbcset(map,scr,121);
1981 1622 tempdcs.bombdoorcombo_d[1]=tdcmbdat(map,scr,122);
1982 1622 tempdcs.bombdoorcset_d[1]=tdcmbcset(map,scr,122);
1983 1622 tempdcs.walkthroughcombo[1]=tdcmbdat(map,scr,34);
1984 1622 tempdcs.walkthroughcset[1]=tdcmbdat(map,scr,34);
1985
1986 //left
1987 // TheMaps[i*MAPSCRS+j].warpdmap=TheOldMap.warpdmap;
1988
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1989 {
1990
2/2
✓ Branch 0 taken 87588 times.
✓ Branch 1 taken 14598 times.
102186 for(int32_t j=0; j<6; j++)
1991 {
1992 87588 tempdcs.doorcombo_l[i][j]=tdcmbdat(map,scr,doortranslations_l[i][j]);
1993 87588 tempdcs.doorcset_l[i][j]=tdcmbcset(map,scr,doortranslations_l[i][j]);
1994 87588 }
1995 14598 }
1996
1997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1622 times.
1622 for(int32_t j=0; j>6; j++)
1998 {
1999 if((j!=2)&&(j!=3))
2000 {
2001 tempdcs.doorcombo_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_l[dt_bomb][j]];
2002 tempdcs.doorcset_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_l[dt_bomb][j]];
2003 }
2004 }
2005
2006 1622 tempdcs.bombdoorcombo_l[0]=0;
2007 1622 tempdcs.bombdoorcset_l[0]=tdcmbcset(map,scr,115);
2008 1622 tempdcs.bombdoorcombo_l[1]=tdcmbdat(map,scr,115);
2009 1622 tempdcs.bombdoorcset_l[1]=tdcmbcset(map,scr,115);
2010 1622 tempdcs.bombdoorcombo_l[2]=0;
2011 1622 tempdcs.bombdoorcset_l[2]=tdcmbcset(map,scr,115);
2012 1622 tempdcs.walkthroughcombo[2]=tdcmbdat(map,scr,34);
2013 1622 tempdcs.walkthroughcset[2]=tdcmbdat(map,scr,34);
2014
2015 //right
2016
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
2017 {
2018
2/2
✓ Branch 0 taken 87588 times.
✓ Branch 1 taken 14598 times.
102186 for(int32_t j=0; j<6; j++)
2019 {
2020 87588 tempdcs.doorcombo_r[i][j]=tdcmbdat(map,scr,doortranslations_r[i][j]);
2021 87588 tempdcs.doorcset_r[i][j]=tdcmbcset(map,scr,doortranslations_r[i][j]);
2022 87588 }
2023 14598 }
2024
2025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1622 times.
1622 for(int32_t j=0; j>6; j++)
2026 {
2027 if((j!=2)&&(j!=3))
2028 {
2029 tempdcs.doorcombo_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_r[dt_bomb][j]];
2030 tempdcs.doorcset_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_r[dt_bomb][j]];
2031 }
2032 }
2033
2034 1622 tempdcs.bombdoorcombo_r[0]=0;
2035 1622 tempdcs.bombdoorcset_r[0]=tdcmbcset(map,scr,124);
2036 1622 tempdcs.bombdoorcombo_r[1]=tdcmbdat(map,scr,124);
2037 1622 tempdcs.bombdoorcset_r[1]=tdcmbcset(map,scr,124);
2038 1622 tempdcs.bombdoorcombo_r[2]=0;
2039 1622 tempdcs.bombdoorcset_r[2]=tdcmbcset(map,scr,124);
2040 1622 tempdcs.walkthroughcombo[3]=tdcmbdat(map,scr,34);
2041 1622 tempdcs.walkthroughcset[3]=tdcmbdat(map,scr,34);
2042
2043 int32_t k;
2044
2045
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 3582 times.
3590 for(k=0; k<door_combo_set_count; k++)
2046 {
2047
2/2
✓ Branch 0 taken 1614 times.
✓ Branch 1 taken 1968 times.
3582 if(DoorComboSets[k]==tempdcs)
2048 {
2049 1614 break;
2050 }
2051 1968 }
2052
2053
2/2
✓ Branch 0 taken 1614 times.
✓ Branch 1 taken 8 times.
1622 if(k==door_combo_set_count)
2054 {
2055 8 DoorComboSets[k]=tempdcs;
2056 8 sprintf(DoorComboSets[k].name, "Door Combo Set %d", k);
2057 8 ++door_combo_set_count;
2058 8 }
2059
2060 1622 return k;
2061 /*
2062 doorcombo_u[9][4];
2063 doorcset_u[9][4];
2064 doorcombo_d[9][4];
2065 doorcset_d[9][4];
2066 doorcombo_l[9][6];
2067 doorcset_l[9][6];
2068 doorcombo_r[9][6];
2069 doorcset_r[9][6];
2070 bombdoorcombo_u[2];
2071 bombdoorcset_u[2];
2072 bombdoorcombo_d[2];
2073 bombdoorcset_d[2];
2074 bombdoorcombo_l[3];
2075 bombdoorcset_l[3];
2076 bombdoorcombo_r[3];
2077 bombdoorcset_r[3];
2078 walkthroughcombo[4];
2079 walkthroughcset[4];
2080 */
2081 7072 }
2082
2083 905216 INLINE int32_t tcmbdat2(int32_t map, int32_t scr, int32_t pos)
2084 {
2085 905216 return (TheMaps[map*MAPSCRS+TEMPLATE2].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
2086 }
2087
2088 905216 INLINE int32_t tcmbcset2(int32_t map, int32_t pos)
2089 {
2090
2091 905216 return TheMaps[map*MAPSCRS+TEMPLATE2].cset[pos];
2092 }
2093
2094 905216 INLINE int32_t tcmbflag2(int32_t map, int32_t pos)
2095 {
2096 905216 return TheMaps[map*MAPSCRS+TEMPLATE2].sflag[pos];
2097 }
2098
2099
2100 16 void get_questpwd(char *encrypted_pwd, int16_t pwdkey, char *pwd)
2101 {
2102 char temp_pwd[30];
2103 16 memset(temp_pwd,0,30);
2104
2105
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(pwdkey!=0)
2106 {
2107 16 memcpy(temp_pwd,encrypted_pwd,30);
2108 16 temp_pwd[29]=0;
2109
2110
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 16 times.
496 for(int32_t i=0; i<30; i++)
2111 {
2112 480 temp_pwd[i] -= pwdkey;
2113 480 int32_t t=pwdkey>>15;
2114 480 pwdkey = (pwdkey<<1)+t;
2115 480 }
2116 16 }
2117
2118 16 memcpy(pwd,temp_pwd,30);
2119 16 }
2120
2121
2122 92 bool devpwd()
2123 {
2124 92 return true; // TODO !!
2125 #ifdef _DEBUG
2126 return true;
2127 #endif
2128 return !strcmp(zc_get_config("dev","pwd","",App::zquest), (char*)clavio);
2129 }
2130 bool check_questpwd(zquestheader *Header, char *pwd)
2131 {
2132 #if DEVLEVEL > 3
2133 return true;
2134 #endif
2135
2136 if (devpwd()) return true;
2137 if ( (!strcmp(pwd, (char*)clavio)) ) return true;
2138 cvs_MD5Context ctx;
2139 uint8_t md5sum[16];
2140
2141 cvs_MD5Init(&ctx);
2142 cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd));
2143 cvs_MD5Final(md5sum, &ctx);
2144
2145 return (memcmp(Header->pwd_hash,md5sum,16)==0);
2146 }
2147
2148 121 void print_quest_metadata(zquestheader const& tempheader, char const* path, byte qst_num)
2149 {
2150 121 zprint2("\n");
2151 121 zprint2("[ZQUEST CREATOR METADATA]\n");
2152
1/2
✓ Branch 0 taken 121 times.
✗ Branch 1 not taken.
121 if(qst_num < moduledata.max_quest_files)
2153 zprint2("Loading module quest %d\n", qst_num+1);
2154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121 times.
121 if(path) zprint2("Loading '%s'\n", path);
2155
2/2
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 4 times.
121 if ( tempheader.new_version_id_main > 0 )
2156 {
2157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117 times.
117 if(tempheader.new_version_id_fourth > 0)
2158 zprint2("Last saved in ZQuest Version %d.%d.%d.%d ",
2159 tempheader.new_version_id_main,tempheader.new_version_id_second,
2160 tempheader.new_version_id_third,tempheader.new_version_id_fourth);
2161 117 else zprint2("Last saved in ZQuest Version: %d.%d.%d ",
2162 117 tempheader.new_version_id_main,tempheader.new_version_id_second,
2163 117 tempheader.new_version_id_third);
2164 117 }
2165 else
2166 {
2167
1/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 switch ( tempheader.zelda_version )
2168 {
2169 case 0x255:
2170 {
2171 zprint2("Last saved in ZQuest Version: 2.55.0, %s: %d", tempheader.getAlphaStr(), tempheader.getAlphaVer());
2172 break;
2173 }
2174 case 0x254:
2175 {
2176 zprint2("Last saved in ZQuest Version: 2.54.0, Alpha Build ID: %d", tempheader.build);
2177 break;
2178 }
2179 case 0x250:
2180 {
2181 switch(tempheader.build)
2182 {
2183 case 19:
2184 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 1"); break;
2185 case 20:
2186 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 2"); break;
2187 case 21:
2188 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 3"); break;
2189 case 22:
2190 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 4"); break;
2191 case 23:
2192 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 5"); break;
2193 case 24:
2194 zprint2("Last saved in ZQuest Version: 2.50.0, Release"); break;
2195 case 25:
2196 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 1"); break;
2197 case 26:
2198 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 2"); break;
2199 case 27:
2200 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 3"); break;
2201 case 28:
2202 zprint2("Last saved in ZQuest Version: 2.50.1, Release"); break;
2203 case 29:
2204 zprint2("Last saved in ZQuest Version: 2.50.2, Release"); break;
2205 case 30:
2206 zprint2("Last saved in ZQuest Version: 2.50.3, Gamma 1"); break;
2207 case 31:
2208 zprint2("Last saved in ZQuest Version: 2.53.0, Prior to Gamma 3"); break;
2209 case 32:
2210 zprint2("Last saved in ZQuest Version: 2.53.0"); break;
2211 case 33:
2212 zprint2("Last saved in ZQuest Version: 2.53.1"); break;
2213 default:
2214 zprint2("Last saved in ZQuest Version: %x, Build %d", tempheader.zelda_version,tempheader.build); break;
2215
2216 }
2217 break;
2218 }
2219
2220 case 0x211:
2221 {
2222 zprint2("Last saved in ZQuest Version: 2.11, Beta %d", tempheader.build); break;
2223 }
2224 case 0x210:
2225 {
2226 zprint2("Last saved in ZQuest Version: 2.10.x");
2227 if ( tempheader.build ) zprint2("Beta/Build %d\n", tempheader.build);
2228 break;
2229 }
2230 /* These versions cannot be handled here; they will be incorrect at this time. -Z
2231 case 0x193:
2232 {
2233 zprint2("Last saved in ZQuest Version: 1.93, Beta %d\n", tempheader.build); break;
2234 }
2235 case 0x192:
2236 {
2237 zprint2("Last saved in ZQuest Version: 1.92, Beta %d\n", tempheader.build); break;
2238 }
2239 case 0x190:
2240 {
2241 zprint2("Last saved in ZQuest Version: 1.90, Beta/Build %d\n", tempheader.build); break;
2242 }
2243 case 0x184:
2244 {
2245 zprint2("Last saved in ZQuest Version: 1.84, Beta/Build %d\n", tempheader.build); break;
2246 }
2247 case 0x183:
2248 {
2249 zprint2("Last saved in ZQuest Version: 1.83, Beta/Build %d\n", tempheader.build); break;
2250 }
2251 case 0x180:
2252 {
2253 zprint2("Last saved in ZQuest Version: 1.80, Beta/Build %d\n", tempheader.build); break;
2254 }
2255 default:
2256 {
2257 zprint2("Last saved in ZQuest Version: %x, Beta %d\n", tempheader.zelda_version,tempheader.build); break;
2258 }
2259 */
2260 }
2261 }
2262
3/4
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 28 times.
121 if(!tempheader.is_legacy() && tempheader.getAlphaVer())
2263 28 zprint2("%s\n", tempheader.getAlphaVerStr());
2264 93 else zprint2("\n");
2265
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 28 times.
121 if ( tempheader.made_in_module_name[0] ) zprint2("Created with ZC Module: %s\n\n", tempheader.made_in_module_name);
2266
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 28 times.
121 if ( tempheader.new_version_devsig[0] ) zprint2("Developr Signoff by: %s\n", tempheader.new_version_devsig);
2267
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 28 times.
121 if ( tempheader.new_version_compilername[0] ) zprint2("Compiled with: %s, (ID: %d)\n", tempheader.new_version_compilername, tempheader.compilerid);
2268
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 28 times.
121 if ( tempheader.new_version_compilerversion[0] ) zprint2("Compiler Version: %s, (%d,%d,%d,%d)\n", tempheader.new_version_compilerversion,tempheader.compilerversionnumber_first,tempheader.compilerversionnumber_second,tempheader.compilerversionnumber_third,tempheader.compilerversionnumber_fourth);
2269
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 117 times.
121 if ( tempheader.product_name[0] ) zprint2("Project ID: %s\n", tempheader.product_name);
2270
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 28 times.
121 if ( tempheader.new_version_id_date_day ) zprint2("Editor Built at date and time: %d-%d-%d at @ %s %s\n", tempheader.new_version_id_date_day, tempheader.new_version_id_date_month, tempheader.new_version_id_date_year, tempheader.build_timestamp, tempheader.build_timezone);
2271 121 zprint2("\n");
2272 121 }
2273
2274 129 int32_t readheader(PACKFILE *f, zquestheader *Header, byte printmetadata)
2275 {
2276 int32_t dummy;
2277 zquestheader tempheader;
2278 char dummybuf[80];
2279 byte temp_map_count;
2280 byte temp_midi_flags[MIDIFLAGS_SIZE];
2281 word version;
2282 char temp_pwd[30], temp_pwd2[30];
2283 int16_t temp_pwdkey;
2284 cvs_MD5Context ctx;
2285 129 memset(temp_midi_flags, 0, MIDIFLAGS_SIZE);
2286 129 memset(&tempheader, 0, sizeof(tempheader));
2287 129 memset(FFCore.quest_format, 0, sizeof(FFCore.quest_format));
2288
2289
2290
2291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(!pfread(tempheader.id_str,sizeof(tempheader.id_str),f)) // first read old header
2292 {
2293 Z_message("Unable to read header string\n");
2294 return qe_invalid;
2295 }
2296
2297 // check header
2298
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2299 {
2300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(strcmp(tempheader.id_str,QH_IDSTR))
2301 {
2302 Z_message("Invalid header string: '%s' (was expecting '%s' or '%s')\n", tempheader.id_str, QH_IDSTR, QH_NEWIDSTR);
2303 return qe_invalid;
2304 }
2305 4 }
2306
2307 129 int32_t templatepath_len=0;
2308
2309 129 tempheader.external_zinfo = false;
2310 129 read_zinfo = false;
2311
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(!strcmp(tempheader.id_str,QH_IDSTR)) //pre-1.93 version
2312 {
2313 byte padding;
2314
2315
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&padding,f))
2316 {
2317 return qe_invalid;
2318 }
2319
2320
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&tempheader.zelda_version,f))
2321 {
2322 return qe_invalid;
2323 }
2324
2325 4 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2326
2327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version > ZELDA_VERSION)
2328 {
2329 return qe_version;
2330 }
2331
2332 4 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2333
2334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(strcmp(tempheader.id_str,QH_IDSTR))
2335 {
2336 return qe_invalid;
2337 }
2338
2339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(bad_version(tempheader.zelda_version))
2340 {
2341 return qe_obsolete;
2342 }
2343
2344
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&tempheader.internal,f))
2345 {
2346 return qe_invalid;
2347 }
2348
2349
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.quest_number,f))
2350 {
2351 return qe_invalid;
2352 }
2353
2354 4 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2355
2356
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[0],2,f))
2357 {
2358 return qe_invalid;
2359 }
2360
2361
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&temp_map_count,f))
2362 {
2363 return qe_invalid;
2364 }
2365
2366 4 FFCore.quest_format[qMapCount] = temp_map_count;
2367
2368
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.old_str_count,f))
2369 {
2370 return qe_invalid;
2371 }
2372
2373
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2374 {
2375 return qe_invalid;
2376 }
2377
2378
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(temp_midi_flags,4,f))
2379 {
2380 return qe_invalid;
2381 }
2382
2383
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2384 {
2385 return qe_invalid;
2386 }
2387
2388
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(dummybuf,14,f))
2389 {
2390 return qe_invalid;
2391 }
2392
2393
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[2],2,f))
2394 {
2395 return qe_invalid;
2396 }
2397
2398
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&dummybuf,f))
2399 {
2400 return qe_invalid;
2401 }
2402
2403
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.version,9,f))
2404 {
2405 return qe_invalid;
2406 }
2407
2408
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2409 {
2410 return qe_invalid;
2411 }
2412 // These fields are expected to end in null bytes!
2413 4 tempheader.title[sizeof(tempheader.title)-1] = 0;
2414
2415
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2416 {
2417 return qe_invalid;
2418 }
2419 4 tempheader.author[sizeof(tempheader.author)-1] = 0;
2420
2421
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&padding,f))
2422 {
2423 return qe_invalid;
2424 }
2425
2426
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&temp_pwdkey,f))
2427 {
2428 return qe_invalid;
2429 }
2430
2431
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(temp_pwd,30,f))
2432 {
2433 return qe_invalid;
2434 }
2435
2436 4 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2437 4 cvs_MD5Init(&ctx);
2438 4 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2439 4 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2440
2441
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version < 0x177) // lacks new header stuff...
2442 {
2443 //memset(tempheader.minver,0,20); // char minver[9], byte build, byte foo[10]
2444 // Not anymore...
2445 memset(tempheader.minver,0,17);
2446 tempheader.build=0;
2447 tempheader.use_keyfile=0;
2448 memset(tempheader.old_foo, 0, 9);
2449 }
2450 else
2451 {
2452
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.minver,9,f))
2453 {
2454 return qe_invalid;
2455 }
2456
2457
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.build,f))
2458 {
2459 return qe_invalid;
2460 }
2461
2462 4 FFCore.quest_format[vBuild] = tempheader.build;
2463
2464
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.use_keyfile,f))
2465 {
2466 return qe_invalid;
2467 }
2468
2469
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(dummybuf,9,f))
2470 {
2471 return qe_invalid;
2472 }
2473 } // starting at minver
2474
2475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version < 0x187) // lacks newer header stuff...
2476 {
2477 memset(&quest_rules[4],0,16); // word rules3..rules10
2478 }
2479 else
2480 {
2481
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[4],16,f)) // read new header additions
2482 {
2483 return qe_invalid; // starting at rules3
2484 }
2485
2486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version <= 0x190)
2487 {
2488 4 set_qr(qr_MEANPLACEDTRAPS,0);
2489 4 }
2490 }
2491
2492
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2493 ((tempheader.zelda_version == 0x192)&&(tempheader.build<149)))
2494 {
2495 4 set_qr(qr_BRKNSHLDTILES,(get_qr(qr_BRKBLSHLDS_DEP)));
2496 4 set_bit(deprecated_rules,qr_BRKBLSHLDS_DEP,1);
2497 4 set_qr(qr_BRKBLSHLDS_DEP,1);
2498 4 }
2499
2500
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(tempheader.zelda_version >= 0x192) // lacks newer header stuff...
2501 {
2502 byte *mf=temp_midi_flags;
2503
2504 if((tempheader.zelda_version == 0x192)&&(tempheader.build<178))
2505 {
2506 mf=(byte*)dummybuf;
2507 }
2508
2509 if(!pfread(mf,32,f)) // read new header additions
2510 {
2511 return qe_invalid; // starting at foo2
2512 }
2513
2514 if(!pfread(dummybuf,18,f)) // read new header additions
2515 {
2516 return qe_invalid; // starting at foo2
2517 }
2518 }
2519
2520
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2521 ((tempheader.zelda_version == 0x192)&&(tempheader.build<145)))
2522 {
2523 4 memset(tempheader.templatepath,0,2048);
2524 4 }
2525 else
2526 {
2527 if(!pfread(tempheader.templatepath,280,f)) // read templatepath
2528 {
2529 return qe_invalid;
2530 }
2531 }
2532
2533
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2534 ((tempheader.zelda_version == 0x192)&&(tempheader.build<186)))
2535 {
2536 4 tempheader.use_keyfile=0;
2537 4 }
2538 4 }
2539 else
2540 {
2541 //section id
2542
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(!p_mgetl(&dummy,f))
2543 {
2544 return qe_invalid;
2545 }
2546
2547 //section version info
2548
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&version,f))
2549 {
2550 return qe_invalid;
2551 }
2552
2553 125 FFCore.quest_format[vHeader] = version;
2554
2555
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&dummy,f))
2556 {
2557 return qe_invalid;
2558 }
2559
2560 //section size
2561
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&dummy,f))
2562 {
2563 return qe_invalid;
2564 }
2565
2566 //finally... section data
2567
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&tempheader.zelda_version,f))
2568 {
2569 return qe_invalid;
2570 }
2571
2572 125 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2573
2574 //do some quick checking...
2575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(tempheader.zelda_version > ZELDA_VERSION)
2576 {
2577 return qe_version;
2578 }
2579
2580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2581 {
2582 return qe_invalid;
2583 }
2584
2585
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(bad_version(tempheader.zelda_version))
2586 {
2587 return qe_obsolete;
2588 }
2589
2590
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_getc(&tempheader.build,f))
2591 {
2592 return qe_invalid;
2593 }
2594
2595 125 FFCore.quest_format[vBuild] = tempheader.build;
2596
2597
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 113 times.
125 if(version<3)
2598 {
2599
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!pfread(temp_pwd,30,f))
2600 {
2601 return qe_invalid;
2602 }
2603
2604
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&temp_pwdkey,f))
2605 {
2606 return qe_invalid;
2607 }
2608
2609 12 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2610 12 cvs_MD5Init(&ctx);
2611 12 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2612 12 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2613 12 }
2614 else
2615 {
2616
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!pfread(tempheader.pwd_hash,sizeof(tempheader.pwd_hash),f))
2617 {
2618 return qe_invalid;
2619 }
2620 }
2621
2622
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&tempheader.internal,f))
2623 {
2624 return qe_invalid;
2625 }
2626
2627
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_getc(&tempheader.quest_number,f))
2628 {
2629 return qe_invalid;
2630 }
2631
2632 125 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2633
2634 125 size_t versz = version < 8 ? 9 : 16;
2635
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!pfread(tempheader.version,versz,f))
2636 {
2637 return qe_invalid;
2638 }
2639
2640 //FFCore.quest_format[qQuestVersion] = tempheader.version;
2641 //needs to be copied as char[9] or stored as a s.str
2642
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!pfread(tempheader.minver,versz,f))
2643 {
2644 return qe_invalid;
2645 }
2646
2647 //FFCore.quest_format[qMinQuestVersion] = tempheader.minver;
2648
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2649 {
2650 return qe_invalid;
2651 }
2652 125 tempheader.title[sizeof(tempheader.title)-1] = 0;
2653
2654
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2655 {
2656 return qe_invalid;
2657 }
2658 125 tempheader.author[sizeof(tempheader.author)-1] = 0;
2659
2660
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_getc(&tempheader.use_keyfile,f))
2661 {
2662 return qe_invalid;
2663 }
2664
2665 /*
2666 if(!pfread(tempheader.data_flags,sizeof(tempheader.data_flags),f))
2667 {
2668 return qe_invalid;
2669 }
2670 */
2671
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2672 {
2673 return qe_invalid;
2674 }
2675
2676
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!pfread(&dummybuf,4,f))
2677 {
2678 return qe_invalid;
2679 }
2680
2681
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2682 {
2683 return qe_invalid;
2684 }
2685
2686
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!pfread(dummybuf,14,f))
2687 {
2688 return qe_invalid;
2689 }
2690
2691 125 templatepath_len=sizeof(tempheader.templatepath);
2692
2693
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(version==1)
2694 {
2695 12 templatepath_len=280;
2696 12 }
2697
2698
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!pfread(tempheader.templatepath,templatepath_len,f))
2699 {
2700 return qe_invalid;
2701 }
2702
2703
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_getc(&temp_map_count,f))
2704 {
2705 return qe_invalid;
2706 }
2707
2708
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if(version>=4)
2709 {
2710
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.new_version_id_main,f))
2711 {
2712 return qe_invalid;
2713 }
2714
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.new_version_id_second,f))
2715 {
2716 return qe_invalid;
2717 }
2718
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.new_version_id_third,f))
2719 {
2720 return qe_invalid;
2721 }
2722
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.new_version_id_fourth,f))
2723 {
2724 return qe_invalid;
2725 }
2726
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.new_version_id_alpha,f))
2727 {
2728 return qe_invalid;
2729 }
2730
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.new_version_id_beta,f))
2731 {
2732 return qe_invalid;
2733 }
2734
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.new_version_id_gamma,f))
2735 {
2736 return qe_invalid;
2737 }
2738
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.new_version_id_release,f))
2739 {
2740 return qe_invalid;
2741 }
2742
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetw(&tempheader.new_version_id_date_year,f))
2743 {
2744 return qe_invalid;
2745 }
2746
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&tempheader.new_version_id_date_month,f))
2747 {
2748 return qe_invalid;
2749 }
2750
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&tempheader.new_version_id_date_day,f))
2751 {
2752 return qe_invalid;
2753 }
2754
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&tempheader.new_version_id_date_hour,f))
2755 {
2756 return qe_invalid;
2757 }
2758
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&tempheader.new_version_id_date_minute,f))
2759 {
2760 return qe_invalid;
2761 }
2762
2763
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!pfread(tempheader.new_version_devsig,256,f))
2764 {
2765 return qe_invalid;
2766 }
2767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(!strcmp(tempheader.new_version_devsig, "Venrob"))
2768 strcpy(tempheader.new_version_devsig, "EmilyV99");
2769
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!pfread(tempheader.new_version_compilername,256,f))
2770 {
2771 return qe_invalid;
2772 }
2773
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!pfread(tempheader.new_version_compilerversion,256,f))
2774 {
2775 return qe_invalid;
2776 }
2777
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!pfread(tempheader.product_name,1024,f))
2778 {
2779 return qe_invalid;
2780 }
2781
2782
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&tempheader.compilerid,f))
2783 {
2784 return qe_invalid;
2785 }
2786
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.compilerversionnumber_first,f))
2787 {
2788 return qe_invalid;
2789 }
2790
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.compilerversionnumber_second,f))
2791 {
2792 return qe_invalid;
2793 }
2794
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.compilerversionnumber_third,f))
2795 {
2796 return qe_invalid;
2797 }
2798
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.compilerversionnumber_fourth,f))
2799 {
2800 return qe_invalid;
2801 }
2802
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetw(&tempheader.developerid,f))
2803 {
2804 return qe_invalid;
2805 }
2806
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!pfread(tempheader.made_in_module_name,1024,f))
2807 {
2808 return qe_invalid;
2809 }
2810
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!pfread(tempheader.build_datestamp,256,f))
2811 {
2812 return qe_invalid;
2813 }
2814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(!pfread(tempheader.build_timestamp,256,f))
2815 {
2816 return qe_invalid;
2817 }
2818 36 }
2819 else // <4
2820 {
2821 89 tempheader.new_version_id_main = 0;
2822 89 tempheader.new_version_id_second = 0;
2823 89 tempheader.new_version_id_third = 0;
2824 89 tempheader.new_version_id_fourth = 0;
2825 89 tempheader.new_version_id_alpha = 0;
2826 89 tempheader.new_version_id_beta = 0;
2827 89 tempheader.new_version_id_gamma = 0;
2828 89 tempheader.new_version_id_release = 0;
2829 89 tempheader.new_version_id_date_year = 0;
2830 89 tempheader.new_version_id_date_month = 0;
2831 89 tempheader.new_version_id_date_day = 0;
2832 89 tempheader.new_version_id_date_hour = 0;
2833 89 tempheader.new_version_id_date_minute = 0;
2834
2835 89 memset(tempheader.new_version_devsig, 0, 256);
2836 89 memset(tempheader.new_version_compilername, 0, 256);
2837 89 memset(tempheader.new_version_compilerversion, 0, 256);
2838 89 memset(tempheader.product_name, 0, 1024);
2839 89 strcpy(tempheader.product_name, "ZQuest Creator Suite");
2840
2841 89 tempheader.compilerid = 0;
2842 89 tempheader.compilerversionnumber_first = 0;
2843 89 tempheader.compilerversionnumber_second = 0;
2844 89 tempheader.compilerversionnumber_third = 0;
2845 89 tempheader.compilerversionnumber_fourth = 0;
2846 89 tempheader.developerid = 0;
2847
2848 89 memset(tempheader.made_in_module_name, 0, 1024);
2849 89 memset(tempheader.build_datestamp, 0, 256);
2850 89 memset(tempheader.build_timestamp, 0, 256);
2851 }
2852
2853
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if ( version >= 5 )
2854 {
2855
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!pfread(tempheader.build_timezone,6,f))
2856 {
2857 return qe_invalid;
2858 }
2859 36 }
2860 else // < 5
2861 {
2862 89 memset(tempheader.build_timezone, 0, 6);
2863 }
2864
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 36 times.
125 if ( version >= 6 )
2865 {
2866 byte b;
2867
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&b,f))
2868 {
2869 return qe_invalid;
2870 }
2871 36 tempheader.external_zinfo = b?true:false;
2872 36 read_zinfo = true;
2873 36 }
2874
2875
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if(version >= 7)
2876 {
2877
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&(tempheader.new_version_is_nightly),f))
2878 {
2879 return qe_invalid;
2880 }
2881 36 }
2882 else
2883 {
2884 89 tempheader.new_version_is_nightly = false;
2885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 if(tempheader.zelda_version < 0x255)
2886 {
2887
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
89 switch(tempheader.zelda_version)
2888 {
2889 case 0x254:
2890 tempheader.new_version_id_main = 2;
2891 tempheader.new_version_id_second = 54;
2892 break;
2893 case 0x250:
2894
6/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 22 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 24 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 15 times.
✓ Branch 14 taken 10 times.
✓ Branch 15 taken 1 times.
77 switch(tempheader.build)
2895 {
2896 case 19:
2897 tempheader.new_version_id_main = 2;
2898 tempheader.new_version_id_second = 50;
2899 tempheader.new_version_id_gamma = 1;
2900 break;
2901 case 20:
2902 tempheader.new_version_id_main = 2;
2903 tempheader.new_version_id_second = 50;
2904 tempheader.new_version_id_gamma = 2;
2905 break;
2906 case 21:
2907 tempheader.new_version_id_main = 2;
2908 tempheader.new_version_id_second = 50;
2909 tempheader.new_version_id_gamma = 3;
2910 break;
2911 case 22:
2912 tempheader.new_version_id_main = 2;
2913 tempheader.new_version_id_second = 50;
2914 tempheader.new_version_id_gamma = 4;
2915 break;
2916 case 23:
2917 tempheader.new_version_id_main = 2;
2918 tempheader.new_version_id_second = 50;
2919 tempheader.new_version_id_gamma = 5;
2920 break;
2921 case 24:
2922 22 tempheader.new_version_id_main = 2;
2923 22 tempheader.new_version_id_second = 50;
2924 22 tempheader.new_version_id_release = -1;
2925 22 break;
2926 case 25:
2927 tempheader.new_version_id_main = 2;
2928 tempheader.new_version_id_second = 50;
2929 tempheader.new_version_id_third = 1;
2930 tempheader.new_version_id_gamma = 1;
2931 break;
2932 case 26:
2933 tempheader.new_version_id_main = 2;
2934 tempheader.new_version_id_second = 50;
2935 tempheader.new_version_id_third = 1;
2936 tempheader.new_version_id_gamma = 2;
2937 break;
2938 case 27:
2939 tempheader.new_version_id_main = 2;
2940 tempheader.new_version_id_second = 50;
2941 tempheader.new_version_id_third = 1;
2942 tempheader.new_version_id_gamma = 3;
2943 break;
2944 case 28:
2945 5 tempheader.new_version_id_main = 2;
2946 5 tempheader.new_version_id_second = 50;
2947 5 tempheader.new_version_id_third = 1;
2948 5 tempheader.new_version_id_release = -1;
2949 5 break;
2950 case 29:
2951 24 tempheader.new_version_id_main = 2;
2952 24 tempheader.new_version_id_second = 50;
2953 24 tempheader.new_version_id_third = 2;
2954 24 tempheader.new_version_id_release = -1;
2955 24 break;
2956 case 30:
2957 tempheader.new_version_id_main = 2;
2958 tempheader.new_version_id_second = 50;
2959 tempheader.new_version_id_third = 3;
2960 tempheader.new_version_id_gamma = 1;
2961 break;
2962 case 31:
2963 15 tempheader.new_version_id_main = 2;
2964 15 tempheader.new_version_id_second = 53;
2965 15 tempheader.new_version_id_gamma = -1;
2966 15 break;
2967 case 32:
2968 10 tempheader.new_version_id_main = 2;
2969 10 tempheader.new_version_id_second = 53;
2970 10 tempheader.new_version_id_release = -1;
2971 10 break;
2972 case 33:
2973 1 tempheader.new_version_id_main = 2;
2974 1 tempheader.new_version_id_second = 53;
2975 1 tempheader.new_version_id_third = 1;
2976 1 break;
2977 }
2978 77 break;
2979
2980 case 0x211:
2981 tempheader.new_version_id_main = 2;
2982 tempheader.new_version_id_second = 11;
2983 tempheader.new_version_id_beta = tempheader.build;
2984 break;
2985 case 0x210:
2986 12 tempheader.new_version_id_main = 2;
2987 12 tempheader.new_version_id_second = 10;
2988 12 tempheader.new_version_id_beta = tempheader.build;
2989 12 break;
2990 }
2991 89 }
2992 }
2993
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
125 if(printmetadata || __isZQuest)
2994 {
2995 print_quest_metadata(tempheader, loading_qst_name, loading_qst_num);
2996 }
2997 }
2998
2999 //{ Version Warning
3000 129 int32_t vercmp = tempheader.compareVer();
3001 129 int32_t astatecmp = compare(int32_t(tempheader.getAlphaState()), ALPHA_STATE);
3002 129 int32_t avercmp = compare(tempheader.getAlphaVer(), ALPHA_VER);
3003
4/6
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
165 if(vercmp > 0 || (!vercmp &&
3004
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 (astatecmp > 0 || (!astatecmp &&
3005 36 avercmp > 0))))
3006 {
3007 bool r = true;
3008 if(loadquest_report)
3009 {
3010 enter_sys_pal();
3011 AlertDialog("Quest saved in newer version",
3012 "This quest was last saved in a newer version of ZQuest."
3013 " Attempting to load this quest may not work correctly; to"
3014 " avoid issues, try loading this quest in at least '" + std::string(tempheader.getVerStr()) + "'"
3015 "\n\nWould you like to continue loading anyway? (Not recommended)",
3016 [&](bool ret,bool)
3017 {
3018 r = ret;
3019 }).show();
3020 exit_sys_pal();
3021 }
3022 if(!r)
3023 return qe_silenterr;
3024 }
3025
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 else if(tempheader.compareDate() > 0)
3026 {
3027 bool r = true;
3028 if(loadquest_report)
3029 {
3030 enter_sys_pal();
3031 AlertDialog("Quest saved in newer build",
3032 fmt::format("This quest was last saved in a newer build of ZQuest, and may have"
3033 " issues loading in this build."
3034 "\n{}"
3035 "\n\nWould you like to continue loading anyway?",
3036 tempheader.getVerCmpStr()),
3037 [&](bool ret,bool)
3038 {
3039 r = ret;
3040 }).show();
3041 exit_sys_pal();
3042 }
3043 if(!r)
3044 return qe_silenterr;
3045 }
3046 //}
3047
3048 129 read_ext_zinfo = tempheader.external_zinfo;
3049
3050 129 memcpy(Header, &tempheader, sizeof(tempheader));
3051 129 map_count=temp_map_count;
3052 129 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
3053
3054 129 return 0;
3055 129 }
3056
3057 131 int32_t readrules(PACKFILE *f, zquestheader *Header)
3058 {
3059 int32_t dummy;
3060 zquestheader tempheader;
3061 131 word s_version=0;
3062 131 dword compatrule_version=0;
3063
3064 131 memcpy(&tempheader, Header, sizeof(tempheader));
3065
3066
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 125 times.
131 if(tempheader.zelda_version >= 0x193)
3067 {
3068 //section version info
3069
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_version,f))
3070 {
3071 return qe_invalid;
3072 }
3073
3074 125 FFCore.quest_format[vRules] = s_version;
3075
3076
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&dummy,f))
3077 {
3078 return qe_invalid;
3079 }
3080
3081
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 36 times.
125 if(s_version > 16)
3082 {
3083
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&compatrule_version,f))
3084 {
3085 return qe_invalid;
3086 }
3087 36 }
3088 125 FFCore.quest_format[vCompatRule] = compatrule_version;
3089
3090 //section size
3091
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&dummy,f))
3092 {
3093 return qe_invalid;
3094 }
3095
3096
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 36 times.
125 if ( s_version < 15 )
3097 {
3098 //finally... section data
3099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 if(!pfread(quest_rules,QUESTRULES_SIZE,f))
3100 {
3101 return qe_invalid;
3102 }
3103 89 }
3104 else
3105 {
3106
3107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(!pfread(quest_rules,QUESTRULES_NEW_SIZE,f))
3108 {
3109 return qe_invalid;
3110 }
3111
3112 }
3113 125 }
3114
3115 //al_trace("Rules version %d\n", s_version);
3116 //{ bunch of compat stuff
3117 131 memcpy(deprecated_rules, quest_rules, QUESTRULES_NEW_SIZE);
3118
3119
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(s_version<2)
3120 {
3121 16 set_qr(14,0);
3122 16 set_qr(27,0);
3123 16 set_qr(28,0);
3124 16 set_qr(29,0);
3125 16 set_qr(30,0);
3126 16 set_qr(32,0);
3127 16 set_qr(36,0);
3128 16 set_qr(49,0);
3129 16 set_qr(50,0);
3130 16 set_qr(51,0);
3131 16 set_qr(68,0);
3132 16 set_qr(75,0);
3133 16 set_qr(76,0);
3134 16 set_qr(98,0);
3135 16 set_qr(110,0);
3136 16 set_qr(113,0);
3137 16 set_qr(116,0);
3138 16 set_qr(102,0);
3139 16 set_qr(132,0);
3140 16 }
3141
3142 //Now, do any updates...
3143
5/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
131 if((tempheader.zelda_version < 0x211)||((tempheader.zelda_version == 0x211)&&(tempheader.build<18)))
3144 {
3145 20 set_qr(qr_SMOOTHVERTICALSCROLLING,1);
3146 20 set_qr(qr_REPLACEOPENDOORS, 1);
3147 20 set_qr(qr_OLDLENSORDER, 1);
3148 20 set_qr(qr_NOFAIRYGUYFIRES, 1);
3149 20 set_qr(qr_TRIGGERSREPEAT, 1);
3150 20 }
3151
3152
5/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
131 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3153 {
3154 8 set_qr(qr_WALLFLIERS,1);
3155 8 }
3156
3157
5/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
131 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<4)))
3158 {
3159 8 set_qr(qr_NOBOMBPALFLASH,1);
3160 8 }
3161
3162
5/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
131 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3163 {
3164 8 set_qr(qr_NOSCROLLCONTINUE,1);
3165 8 }
3166
3167
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(tempheader.zelda_version <= 0x210)
3168 {
3169 16 set_qr(qr_ARROWCLIP,1);
3170 16 }
3171
3172
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 12 times.
131 if(tempheader.zelda_version == 0x210)
3173 {
3174 12 set_qr(qr_NOSCROLLCONTINUE, get_qr(qr_CMBCYCLELAYERS));
3175 12 set_qr(qr_CMBCYCLELAYERS, 0);
3176 12 set_qr(qr_CONT_SWORD_TRIGGERS, 1);
3177 12 }
3178
3179
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(tempheader.zelda_version <= 0x210)
3180 {
3181 16 set_qr(qr_OLDSTYLEWARP,1);
3182 16 set_qr(qr_210_WARPRETURN,1);
3183 16 }
3184
3185 //might not be correct
3186
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
131 if(tempheader.zelda_version < 0x210)
3187 {
3188 4 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP,1);
3189 4 set_qr(qr_OLDTRIBBLES_DEP,1);
3190 4 set_qr(qr_OLDHOOKSHOTGRAB,1);
3191 4 }
3192
3193
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(tempheader.zelda_version < 0x211)
3194 {
3195 16 set_qr(qr_WRONG_BRANG_TRAIL_DIR,1);
3196 16 }
3197
3198
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 131 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
131 if(tempheader.zelda_version == 0x192 && tempheader.build == 163)
3199 {
3200 set_qr(qr_192b163_WARP,1);
3201 }
3202
3203
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 12 times.
131 if(tempheader.zelda_version == 0x210)
3204 {
3205 12 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
3206 12 set_qr(qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
3207 12 set_qr(qr_DMGCOMBOPRI, 0);
3208 12 }
3209
3210
5/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
131 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build<15))
3211 {
3212 20 set_qr(qr_OLDPICKUP,1);
3213 20 }
3214
3215
5/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
131 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build < 18))
3216 {
3217 20 set_qr(qr_NOSOLIDDAMAGECOMBOS, 1);
3218 20 set_qr(qr_ITEMPICKUPSETSBELOW, 1); // broke around build 400
3219 20 }
3220
3221
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(tempheader.zelda_version < 0x250) // version<0x250 checks for beta 18; build was set to 18 prematurely
3222 {
3223 16 set_qr(qr_HOOKSHOTDOWNBUG, 1);
3224 16 }
3225
3226
4/4
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 22 times.
131 if(tempheader.zelda_version == 0x250 && tempheader.build == 24) // Annoying...
3227 {
3228 22 set_qr(qr_PEAHATCLOCKVULN, 1);
3229 22 }
3230
3231
6/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 79 times.
131 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 22)) //22 is 2.50.0 RC4. Gotta set the door repair QR... -Dimi
3232 {
3233 20 set_qr(qr_OLD_DOORREPAIR, 1);
3234 20 }
3235
3236
6/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 79 times.
131 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 20)) //20 is 2.50.0 RC1 and RC2 (cause it didn't get bumped). Okay I'm gonna be honest I have no idea if any 2.50 build was available before RC1, but gonna try and cover my ass here -Dimi
3237 {
3238 20 set_qr(qr_OLD_SECRETMONEY, 1);
3239 20 }
3240
3241
6/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 57 times.
131 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 28)) //28 is 2.50.1 final. Potion bug might have been used, I dunno. -Dimi
3242 {
3243 42 set_qr(qr_OLD_POTION_OR_HC, 1);
3244 42 }
3245
3246
6/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 57 times.
131 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<28))
3247 {
3248 42 set_qr(qr_OFFSCREENWEAPONS, 1);
3249 42 }
3250
3251 //Bombchu fix.
3252
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 77 times.
131 if(tempheader.zelda_version == 0x250)
3253 {
3254
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 22 times.
77 if ( tempheader.build == 24 ) //2.50.0
3255 {
3256 22 set_qr(qr_BOMBCHUSUPERBOMB, 1);
3257 22 }
3258
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 5 times.
77 if ( tempheader.build == 28 ) //2.50.1
3259 {
3260 5 set_qr(qr_BOMBCHUSUPERBOMB, 1);
3261 5 }
3262
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 24 times.
77 if ( tempheader.build == 29 ) //2.50.2
3263 {
3264 24 set_qr(qr_BOMBCHUSUPERBOMB, 0);
3265 24 }
3266
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if ( tempheader.build == 30 ) //2.50.3RC1
3267 {
3268 set_qr(qr_BOMBCHUSUPERBOMB, 0);
3269 }
3270 77 }
3271
3272
6/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 29 times.
✓ Branch 5 taken 52 times.
131 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3273 {
3274 // qr_OFFSETEWPNCOLLISIONFIX
3275 // All 'official' quests need this disabled.
3276 // All 2.10 and lower quests need this enabled to preseve compatability.
3277 // All 2.11 - 2.5.1 quests should have it set also, due to a bug in about half of all the betas.
3278
3279 //~Gleeok
3280 47 set_qr(qr_OFFSETEWPNCOLLISIONFIX, 1); //This has to be set!!!!
3281
3282 // Broke in build 695
3283
3/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27 times.
47 if(tempheader.zelda_version>=0x211 && tempheader.build>=18)
3284 27 set_qr(qr_BROKENSTATUES, 1);
3285 43 }
3286
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
131 if (tempheader.zelda_version <= 0x190)
3287 {
3288 4 set_qr(qr_COPIED_SWIM_SPRITES, 1);
3289 4 }
3290
9/10
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 53 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 37 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 36 times.
131 if ( (tempheader.zelda_version == 0x250 && tempheader.build < 33) || tempheader.zelda_version == 0x254 || tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3291 {
3292 94 set_qr(qr_OLD_SLASHNEXT_SECRETS, 1);
3293 94 }
3294
3295
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if ( (tempheader.zelda_version < 0x211) ) //2.10 water and ladder interaction
3296 {
3297 16 set_qr(qr_OLD_210_WATER, 1);
3298 16 }
3299
3300
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( (tempheader.zelda_version < 0x255 ) || (tempheader.zelda_version == 0x255 && tempheader.build < 51 ) ) //2.10 water and ladder interaction
3301 {
3302 93 set_qr(qr_STEP_IS_FLOAT,0);
3303 93 }
3304
3305
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if ( tempheader.zelda_version < 0x250 )
3306 {
3307 16 set_qr(qr_8WAY_SHOT_SFX, 1);
3308 16 }
3309
3310
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version < 3)
3311 {
3312 16 set_qr(qr_HOLDNOSTOPMUSIC, 1);
3313 16 set_qr(qr_CAVEEXITNOSTOPMUSIC, 1);
3314 16 }
3315
3316
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<4)
3317 {
3318 16 set_qr(10,0);
3319 16 }
3320
3321
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<5)
3322 {
3323 16 set_qr(27,0);
3324 16 }
3325
3326
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<6)
3327 {
3328 16 set_qr(46,0);
3329 16 }
3330
3331
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<7) // January 2008
3332 {
3333 16 set_qr(qr_HEARTSREQUIREDFIX,0);
3334 16 set_qr(qr_PUSHBLOCKCSETFIX,1);
3335 16 }
3336
3337
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 113 times.
129 if(s_version<8)
3338 {
3339 16 set_qr(12, 0);
3340 16 }
3341 else
3342 {
3343 113 set_bit(deprecated_rules, 12, 0);
3344 }
3345
3346
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<9) // October 2008
3347 {
3348 16 set_qr(qr_NOROPE2FLASH_DEP,0);
3349 16 set_qr(qr_NOBUBBLEFLASH_DEP,0);
3350 16 set_qr(qr_GHINI2BLINK_DEP,0);
3351 16 set_qr(qr_PHANTOMGHINI2_DEP,0);
3352 16 }
3353
3354
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<10) // December 2008
3355 {
3356 16 set_qr(qr_NOCLOCKS_DEP,0);
3357 16 set_qr(qr_ALLOW10RUPEEDROPS_DEP,0);
3358 16 }
3359
3360
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<11) // April 2009
3361 {
3362 16 set_qr(qr_SLOWENEMYANIM_DEP,0);
3363 16 }
3364
3365 // This served no purpose.
3366 // if(s_version<12) // December 2009
3367 // {
3368 // set_qr(qr_BRKBLSHLDS_DEP,0);
3369 // set_qr(qr_OLDTRIBBLES_DEP,0);
3370 // }
3371
3372 //if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 24))
3373
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version < 13)
3374 {
3375 16 set_qr(qr_SHOPCHEAT, 1);
3376 16 }
3377
3378 // Not entirely sure this is the best place for this...
3379 //2.50.2 bitmap offset fix
3380 129 memset(extra_rules, 0, EXTRARULES_SIZE);
3381
6/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 50 times.
129 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3382 {
3383 43 set_er(er_BITMAPOFFSET, 1);
3384 43 set_qr(qr_BITMAPOFFSETFIX, 1);
3385 43 }
3386 //required because quest templates also used this bit, although
3387 //it never did anything, before. -Z
3388
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 77 times.
129 if ( tempheader.zelda_version == 0x250 )
3389 {
3390
5/6
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 53 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 38 times.
77 if( tempheader.build == 29 || tempheader.build == 30 || tempheader.build == 31 )
3391 {
3392 39 set_er(er_BITMAPOFFSET, 0);
3393 39 set_qr(qr_BITMAPOFFSETFIX, 0);
3394 39 }
3395 77 }
3396
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if ( tempheader.zelda_version == 0x254 )
3397 {
3398 set_er(er_BITMAPOFFSET, 0);
3399 set_qr(qr_BITMAPOFFSETFIX, 0);
3400 }
3401
3/4
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
129 if ( tempheader.zelda_version == 0x255 && tempheader.build < 42 ) //QR was added to 255 in this build.
3402 {
3403 set_er(er_BITMAPOFFSET, 0);
3404 set_qr(qr_BITMAPOFFSETFIX, 0);
3405 }
3406 //optimise fast drawing for older versions.
3407
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3408 {
3409 93 set_qr(qr_OLDSPRITEDRAWS, 1);
3410 93 }
3411 //Old eweapon->Parent (was added in 2.54, Alpha 19)
3412 //The change was made in build 43, but I'm setting this to < 42, because quests made in 42 would benefit from this change, and
3413 //older quests can set the rule by hand. We need a new qst.dat again.
3414
4/6
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3415 {
3416 set_qr(qr_OLDEWPNPARENT, 1);
3417 }
3418
4/6
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3419 {
3420 set_qr(qr_OLDCREATEBITMAP_ARGS, 1);
3421 }
3422
4/6
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 45) )
3423 {
3424 set_qr(qr_OLDQUESTMISC, 1);
3425 }
3426
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if ( tempheader.zelda_version < 0x254 )
3427 {
3428 93 set_qr(qr_OLDCREATEBITMAP_ARGS, 0);
3429 93 set_qr(qr_OLDEWPNPARENT, 0);
3430 93 set_qr(qr_OLDQUESTMISC, 0);
3431 93 }
3432
3433 //item scripts continue to run
3434
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3435 {
3436 93 set_qr(qr_ITEMSCRIPTSKEEPRUNNING, 0);
3437 93 set_qr(qr_SCRIPTSRUNINHEROSTEPFORWARD, 0);
3438 93 set_qr(qr_FIXSCRIPTSDURINGSCROLLING, 0);
3439 93 set_qr(qr_SCRIPTDRAWSINWARPS, 0);
3440 93 set_qr(qr_DYINGENEMYESDONTHURTHERO, 0);
3441 93 set_qr(qr_OUTOFBOUNDSENEMIES, 0);
3442 93 set_qr(qr_SPRITEXY_IS_FLOAT, 0);
3443 93 }
3444
3445
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3446 {
3447 93 set_qr(qr_CLEARINITDONSCRIPTCHANGE, 1);
3448 93 }
3449
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3450 {
3451 93 set_qr(qr_TRACESCRIPTIDS, 0);
3452 93 set_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES, 1);
3453 93 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL, 1);
3454 93 set_qr(qr_PARSER_250DIVISION,1);
3455 93 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL,1);
3456 93 set_qr(qr_PARSER_TRUE_INT_SIZE,0);
3457 93 set_qr(qr_PARSER_FORCE_INLINE,0);
3458 93 set_qr(qr_PARSER_BINARY_32BIT,0);
3459
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 2 times.
93 if ( get_qr(qr_SELECTAWPN) )
3460 {
3461 2 set_qr(qr_NO_L_R_BUTTON_INVENTORY_SWAP,1);
3462 //In < 2.55a27, if you had an A+B subscreen, L and R didn't shift through inventory.
3463 //Now they **do**, unless you disable that behaviour.
3464 //For the sake of compatibility, old quests with the A+B subscreen rule enabed
3465 //now enable the disable L/R item swap on load.
3466 2 }
3467
3468 93 }
3469
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3470 {
3471 //Compatibility: Setting the hero's action to rafting was previously disallowed, though legal for scripts to attempt.
3472 93 set_qr(qr_DISALLOW_SETTING_RAFTING, 1);
3473 //Compatibility: The calculation for when to loop an animation did not factor in ASkipY correctly, resulting in
3474 //animations ending earlier than they should.
3475 93 set_qr(qr_BROKEN_ASKIP_Y_FRAMES, 1);
3476 //Enemies would ignore solidity on the top half of combos
3477 93 set_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY, 1);
3478 //Ceiling collison was a bit wonky, including hitting your head before you are near the ceiling or clipping into it slightly.
3479 93 set_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON, 1);
3480 //If an itemdata had a 'frames' of 0, items created of that data would ignore all changes to 'frames'
3481 93 set_qr(qr_0AFRAME_ITEMS_IGNORE_AFRAME_CHANGES, 1);
3482 //Collision used some odd calculations before, and enemies could not be hit back into the top row or left column
3483 93 set_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION, 1);
3484 93 }
3485
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if ( tempheader.zelda_version < 0x255 )
3486 {
3487 93 set_qr(qr_NOFFCWAITDRAW, 1);
3488 93 set_qr(qr_NOITEMWAITDRAW, 1);
3489 93 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3490 93 set_qr(qr_OLD_INIT_SCRIPT_TIMING, 1);
3491 //set_qr(qr_DO_NOT_DEALLOCATE_INIT_AND_SAVELOAD_ARRAYS, 1);
3492 93 }
3493
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 48 ) )
3494 {
3495 93 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3496 93 }
3497
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 52 ) )
3498 {
3499 93 set_qr(qr_OLD_PRINTF_ARGS, 1);
3500 93 }
3501
3502
3503
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 54) )
3504 {
3505 93 set_qr(qr_BROKEN_RING_POWER, 1);
3506 93 }
3507
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 56) )
3508 {
3509 93 set_qr(qr_NO_OVERWORLD_MAP_CHARTING, 1);
3510 93 }
3511
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 57) )
3512 {
3513 93 set_qr(qr_DUNGEONS_USE_CLASSIC_CHARTING, 1);
3514 93 }
3515
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 58) )
3516 {
3517 //Rule used to be 'qr_SETXYBUTTONITEMS', now split.
3518
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if(get_qr(qr_SET_XBUTTON_ITEMS))
3519 set_qr(qr_SET_YBUTTON_ITEMS,1);
3520 93 }
3521
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 59) )
3522 {
3523 93 set_qr(qr_ALLOW_EDITING_COMBO_0,1);
3524 93 }
3525
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 60) )
3526 {
3527 93 set_qr(qr_OLD_CHEST_COLLISION,1);
3528 93 }
3529
3530
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if ( tempheader.zelda_version < 0x254 )
3531 {
3532 93 set_qr(qr_250WRITEEDEFSCRIPT, 1);
3533 93 }
3534 //Sideview spikes in 2.50.0
3535
6/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 55 times.
129 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<27)) //2.50.1RC3
3536 {
3537 38 set_qr(qr_OLDSIDEVIEWSPIKES, 1);
3538 38 }
3539 //more 2.50 fixes -Z
3540
6/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 51 times.
✓ Branch 5 taken 26 times.
129 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<31))
3541 {
3542 67 set_qr(qr_MELEEMAGICCOST, 0);
3543 67 set_qr(qr_GANONINTRO, 0); //This will get flipped later on in the compatrule 11 check. That's why it's turning it off.
3544 67 set_qr(qr_OLDMIRRORCOMBOS, 1);
3545 67 set_qr(qr_BROKENBOOKCOST, 1);
3546 67 set_qr(qr_BROKENCHARINTDRAWING, 1);
3547
3548 67 }
3549
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if(tempheader.zelda_version == 0x254 && tempheader.build<41)
3550 {
3551 //set_qr(qr_MELEEMAGICCOST, get_er(er_MAGICCOSTSWORD));
3552 set_qr(qr_MELEEMAGICCOST, 1);
3553 }
3554
3555
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(tempheader.zelda_version < 0x193)
3556 {
3557 4 set_qr(qr_SHORTDGNWALK, 1);
3558 4 }
3559
3560
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(tempheader.zelda_version < 0x255)
3561 {
3562 93 set_qr(qr_OLDINFMAGIC, 1);
3563 93 }
3564
3565
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if((tempheader.zelda_version < 0x250)) //2.10 and earlier allowed the triforce to Warp Player out of Item Cellars in Dungeons. -Z (15th March, 2019 )
3566 {
3567 16 set_qr(qr_SIDEVIEWTRIFORCECELLAR,1);
3568 16 }
3569
3570
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3571 {
3572 93 set_qr(qr_OLD_F6,1);
3573 93 }
3574
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 49) )
3575 {
3576 93 set_qr(qr_NO_OVERWRITING_HOPPING,1);
3577 93 }
3578
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3579 {
3580 93 set_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT,1);
3581 93 }
3582
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 53) )
3583 {
3584 93 set_qr(qr_BROKEN_OVERWORLD_MINIMAP,1);
3585 93 }
3586 //}
3587
3588
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 1) //Enemies->Secret only affects flag 16-31
3589 93 set_qr(qr_ENEMIES_SECRET_ONLY_16_31,1);
3590
3591
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 2) //Old CSet2 Handling
3592 93 set_qr(qr_OLDCS2,1);
3593
3594
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 3) //Hardcoded Shadow/Spawn/Death anim frames
3595 93 set_qr(qr_HARDCODED_ENEMY_ANIMS,1);
3596
3597
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 4) //Hardcoded Shadow/Spawn/Death anim frames
3598 93 set_qr(qr_OLD_ITEMDATA_SCRIPT_TIMING,1);
3599
3600
4/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 77 times.
129 if(compatrule_version < 5 && tempheader.zelda_version >= 0x250) //Hardcoded Shadow/Spawn/Death anim frames
3601 77 set_qr(qr_NO_LANMOLA_RINGLEADER,1);
3602
3603
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 6) //Step->Secret (Temp) only affects flag 16-31
3604 93 set_qr(qr_STEPTEMP_SECRET_ONLY_16_31,1);
3605
3606
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 7) //'Hit All Triggers->Perm Secret' doesn't trigger temp secrets
3607 93 set_qr(qr_ALLTRIG_PERMSEC_NO_TEMP,1);
3608
3609
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 8) //Hardcoded LItem/Bomb/Clock/Magic Tile Mods
3610 93 set_qr(qr_HARDCODED_LITEM_LTMS,1);
3611
3612
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 9)
3613 {
3614 //Hardcoded BS Patras
3615 93 set_qr(qr_HARDCODED_BS_PATRA,1);
3616 //Hardcoded Patra Inner Eye offsets
3617 93 set_qr(qr_PATRAS_USE_HARDCODED_OFFSETS,1);
3618 //Broken 'Big enemy' animation style
3619 93 set_qr(qr_BROKEN_BIG_ENEMY_ANIMATION,1);
3620 //Broken Attribute 31/32
3621 93 set_qr(qr_BROKEN_ATTRIBUTE_31_32,1);
3622 93 }
3623
3624
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 10) //Shared candle use limits
3625 93 set_qr(qr_CANDLES_SHARED_LIMIT,1);
3626
3627
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 11) //No cross-screen return points
3628 93 set_qr(qr_OLD_RESPAWN_POINTS,1);
3629
3630
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 12)
3631 {
3632 //Old fire trail duration
3633 93 set_qr(qr_OLD_FLAMETRAIL_DURATION,1);
3634 //Old Intro String in Ganon Room Behavior
3635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 if(get_qr(qr_GANONINTRO)) set_qr(qr_GANONINTRO,0);
3636 93 else set_qr(qr_GANONINTRO,1);
3637 93 }
3638
3639
3/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
129 if(compatrule_version < 13 && tempheader.zelda_version >= 0x255) //ANone doesn't reset to originaltile
3640 set_qr(qr_ANONE_NOANIM,1);
3641
3642
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 14) //Old Bridge Combo Behavior
3643 93 set_qr(qr_OLD_BRIDGE_COMBOS,1);
3644
3645
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 15) //Broken Z3 Animation
3646 93 set_qr(qr_BROKEN_Z3_ANIMATION,1);
3647
3648
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 16) //Old Enemy Tile Behavior with Animation (None) Enemies
3649 93 set_qr(qr_OLD_TILE_INITIALIZATION,1);
3650
3651
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 17)
3652 {
3653 //Old Quake/DrawYOffset behavior
3654 //set_qr(qr_OLD_DRAWOFFSET,1);
3655 //I'm leaving this commented cause I doubt it'll break anything and I think the bugfix might be appreciated in older versions.
3656 //On the offchance that it *does* break old quests, fixing it is as simple as uncommenting the set_bit above.
3657 93 }
3658
3659
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 18)
3660 {
3661 //Broken DrawScreen Derivative Functions
3662 93 set_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS,1);
3663 //Scrolling Cancels Charge
3664 93 set_qr(qr_SCROLLING_KILLS_CHARGE,1);
3665 93 }
3666
3667
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 19) //Broken Enemy Item Carrying with Large Enemies
3668 93 set_qr(qr_BROKEN_ITEM_CARRYING,1);
3669
3670
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 20)
3671 93 set_qr(qr_CUSTOMWEAPON_IGNORE_COST,1);
3672
3673
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 21)
3674 {
3675 93 set_qr(qr_LEEVERS_DONT_OBEY_STUN,1);
3676 93 set_qr(qr_GANON_CANT_SPAWN_ON_CONTINUE,1);
3677 93 set_qr(qr_WIZZROBES_DONT_OBEY_STUN,1);
3678 93 set_qr(qr_OLD_BUG_NET,1);
3679 93 set_qr(qr_MANHANDLA_BLOCK_SFX,1);
3680 93 }
3681
3682
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 22)
3683 93 set_qr(qr_BROKEN_KEEPOLD_FLAG,1);
3684
3685
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 23)
3686 93 set_qr(qr_OLD_HALF_MAGIC,1);
3687
3688
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 24)
3689 {
3690 93 set_qr(qr_WARPS_RESTART_DMAPSCRIPT,1);
3691 93 set_qr(qr_DMAP_0_CONTINUE_BUG,1);
3692 93 }
3693
3694
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 25)
3695 {
3696
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 if (get_qr(qr_OLD_FAIRY_LIMIT)) set_qr(qr_OLD_FAIRY_LIMIT,0);
3697 93 else set_qr(qr_OLD_FAIRY_LIMIT,1);
3698 93 set_qr(qr_OLD_SCRIPTED_KNOCKBACK,1);
3699 93 }
3700
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 26)
3701 {
3702 93 set_qr(qr_OLD_KEESE_Z_AXIS,1);
3703 93 set_qr(qr_POLVIRE_NO_SHADOW,1);
3704 93 set_qr(qr_SUBSCR_OLD_SELECTOR,1);
3705 93 }
3706
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 27) //Noticed some junk data in the QR array...
3707 {
3708
2/2
✓ Branch 0 taken 27993 times.
✓ Branch 1 taken 93 times.
28086 for(auto q = qr_POLVIRE_NO_SHADOW+1; q < qr_PARSER_250DIVISION; ++q)
3709 27993 set_qr(q,0);
3710
2/2
✓ Branch 0 taken 10416 times.
✓ Branch 1 taken 93 times.
10509 for(auto q = qr_COMBODATA_INITD_MULT_TENK+1; q < QUESTRULES_NEW_SIZE*8; ++q)
3711 10416 set_qr(q,0);
3712 //This should nuke any remaining junk data... not sure if it affected anything previous. -Em
3713 93 }
3714
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 95 times.
129 if(compatrule_version < 28)
3715 95 set_qr(qr_SUBSCR_BACKWARDS_ID_ORDER,1);
3716
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 95 times.
129 if(compatrule_version < 29)
3717 95 set_qr(qr_OLD_LOCKBLOCK_COLLISION,1);
3718
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 95 times.
129 if(compatrule_version < 30)
3719 {
3720 95 set_qr(qr_DECO_2_YOFFSET,1);
3721 95 set_qr(qr_SCREENSTATE_80s_BUG,1);
3722 95 }
3723
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 95 times.
129 if(compatrule_version < 31)
3724 {
3725 95 set_qr(qr_GOHMA_UNDAMAGED_BUG,1);
3726 95 set_qr(qr_FFCPRELOAD_BUGGED_LOAD,1);
3727 95 }
3728
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 95 times.
129 if(compatrule_version < 32)
3729 95 set_qr(qr_BROKEN_GETPIXEL_VALUE,1);
3730
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 95 times.
129 if(compatrule_version < 33)
3731 95 set_qr(qr_NO_LIFT_SPRITE,1);
3732
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 95 times.
129 if(compatrule_version < 34)
3733 {
3734 95 set_qr(qr_OLD_SIDEVIEW_LANDING_CODE,1);
3735 95 set_qr(qr_OLD_FFC_SPEED_CAP,1);
3736 95 set_qr(qr_OLD_FFC_FUNCTIONALITY,1);
3737 95 set_qr(qr_OLD_WIZZROBE_SUBMERGING,1);
3738 95 }
3739
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 96 times.
129 if(compatrule_version < 35)
3740 {
3741 96 set_qr(qr_ZS_NO_NEG_ARRAY,1);
3742 96 set_qr(qr_BROKEN_INPUT_DOWN_STATE,1);
3743 96 }
3744
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 96 times.
129 if(compatrule_version < 36)
3745 96 set_qr(qr_OLD_SHALLOW_SFX,1);
3746
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 98 times.
129 if(compatrule_version < 37)
3747 98 set_qr(qr_SPARKLES_INHERIT_PROPERTIES,1);
3748
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 98 times.
129 if(compatrule_version < 38)
3749 98 set_qr(qr_BUGGED_LAYERED_FLAGS,1);
3750
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 98 times.
129 if(compatrule_version < 39)
3751 98 set_qr(qr_HARDCODED_FFC_BUSH_DROPS,1);
3752
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 98 times.
129 if(compatrule_version < 40)
3753 98 set_qr(qr_MOVINGBLOCK_FAKE_SOLID,1);
3754
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 99 times.
129 if(compatrule_version < 41)
3755 99 set_qr(qr_BROKENHITBY,1);
3756
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 99 times.
129 if(compatrule_version < 42)
3757 99 set_qr(qr_BROKEN_MOVING_BOMBS,1);
3758
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 99 times.
129 if(compatrule_version < 43)
3759 99 set_qr(qr_OLD_BOMB_HITBOXES,1);
3760
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 99 times.
129 if(compatrule_version < 44)
3761 99 set_qr(qr_SCROLLWARP_NO_RESET_FRAME,1);
3762
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 107 times.
129 if(compatrule_version < 45)
3763 107 set_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME,1);
3764
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 107 times.
129 if(compatrule_version < 46)
3765 107 set_qr(qr_BROKEN_RAFT_SCROLL,1);
3766
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 110 times.
129 if(compatrule_version < 47)
3767 {
3768 110 set_qr(qr_SENSITIVE_SOLID_DAMAGE,1);
3769 110 set_qr(qr_OLD_CONVEYOR_COLLISION,1);
3770 110 }
3771
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 110 times.
129 if(compatrule_version < 48)
3772 110 set_qr(qr_OLD_GUY_HANDLING,1);
3773
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 110 times.
129 if(compatrule_version < 49)
3774 110 set_qr(qr_FAIRY_FLAG_COMPAT,1);
3775
3776 129 set_qr(qr_ANIMATECUSTOMWEAPONS,0);
3777
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if (s_version < 16)
3778 93 set_qr(qr_BROKEN_HORIZONTAL_WEAPON_ANIM,1);
3779
3780 129 memcpy(Header, &tempheader, sizeof(tempheader));
3781
3782 129 return 0;
3783 129 }
3784
3785 1084440 void init_msgstr(MsgStr *str)
3786 {
3787 1084440 str->s = "";
3788 1084440 str->s.shrink_to_fit();
3789 1084440 str->nextstring=0;
3790 1084440 str->tile=0;
3791 1084440 str->cset=0;
3792 1084440 str->trans=false;
3793 1084440 str->font=font_zfont;
3794 1084440 str->y=32;
3795 1084440 str->sfx=18;
3796 1084440 str->listpos=0;
3797 1084440 str->x=24;
3798 1084440 str->w=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 24*8 : 26*8;
3799 1084440 str->h=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 3*8 : 5*8;
3800 1084440 str->hspace=0;
3801 1084440 str->vspace=0;
3802 1084440 str->stringflags=0;
3803 1084440 str->margins[up] = 8;
3804 1084440 str->margins[down] = 0;
3805 1084440 str->margins[left] = 8;
3806 1084440 str->margins[right] = 0;
3807 1084440 str->portrait_tile = 0;
3808 1084440 str->portrait_cset = 0;
3809 1084440 str->portrait_x = 0;
3810 1084440 str->portrait_y = 0;
3811 1084440 str->portrait_tw = 1;
3812 1084440 str->portrait_th = 1;
3813 1084440 str->shadow_type = 0;
3814 1084440 str->shadow_color = 0;
3815 1084440 str->drawlayer = 6;
3816 1084440 }
3817
3818 129 void init_msgstrings(int32_t start, int32_t end)
3819 {
3820
2/4
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 129 times.
129 if(end <= start || end-start > msg_strings_size)
3821 return;
3822
3823
2/2
✓ Branch 0 taken 1056768 times.
✓ Branch 1 taken 129 times.
1056897 for(int32_t i=start; i<end; i++)
3824 {
3825 1056768 init_msgstr(&MsgStrings[i]);
3826 1056768 MsgStrings[i].listpos=i;
3827 1056768 }
3828
3829
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(start==0)
3830 {
3831 129 MsgStrings[0].s = "(None)";
3832 129 MsgStrings[0].listpos = 0;
3833 129 }
3834 129 }
3835
3836 129 int32_t readstrings(PACKFILE *f, zquestheader *Header)
3837 {
3838 129 MsgStr tempMsgString;
3839
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 init_msgstr(&tempMsgString);
3840
3841 129 word temp_msg_count=0;
3842 word temp_expansion[16];
3843 129 memset(temp_expansion, 0, 16*sizeof(word));
3844 129 char buf[8193] = {0};
3845
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(Header->zelda_version < 0x193)
3846 {
3847 byte tempbyte;
3848 4 int32_t strings_to_read=0;
3849
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3850
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
3851 ((Header->zelda_version == 0x192)&&(Header->build<31)))
3852 {
3853 4 strings_to_read=128;
3854 4 temp_msg_count=Header->old_str_count;
3855
3856 // Some sort of string count corruption seems to be common in old quests
3857
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(temp_msg_count>128)
3858 {
3859 temp_msg_count=128;
3860 }
3861 4 }
3862 else if((Header->zelda_version == 0x192)&&(Header->build<140))
3863 {
3864 strings_to_read=255;
3865 temp_msg_count=Header->old_str_count;
3866 }
3867 else
3868 {
3869 if(!p_igetw(&temp_msg_count,f))
3870 {
3871 return qe_invalid;
3872 }
3873
3874 strings_to_read=temp_msg_count;
3875
3876 if(temp_msg_count >= msg_strings_size)
3877 {
3878 Z_message("Reallocating string buffer...\n");
3879
3880 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3881 // return qe_nomem;
3882
3883 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3884 delete[] MsgStrings;
3885 MsgStrings = new MsgStr[MAXMSGS];
3886 msg_strings_size = MAXMSGS;
3887 for(auto q = 0; q < msg_strings_size; ++q)
3888 {
3889 MsgStrings[q].clear();
3890 }
3891 }
3892 }
3893
3894 //reset the message strings
3895
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 init_msgstrings(0,msg_strings_size);
3896
3897
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 4 times.
516 for(int32_t x=0; x<strings_to_read; x++)
3898 {
3899
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 init_msgstr(&tempMsgString);
3900 512 tempMsgString.listpos = x;
3901
3902
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!pfread(buf,73,f))
3903 {
3904 return qe_invalid;
3905 }
3906
3907 512 buf[74] = '\0';
3908
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 tempMsgString.s = buf;
3909
3910
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f))
3911 {
3912 return qe_invalid;
3913 }
3914
3915
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
512 if((Header->zelda_version < 0x192)||
3916 ((Header->zelda_version == 0x192)&&(Header->build<148)))
3917 {
3918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
512 tempMsgString.nextstring=tempbyte?x+1:0;
3919
3920
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f))
3921 {
3922 return qe_invalid;
3923 }
3924
3925
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f))
3926 {
3927 return qe_invalid;
3928 }
3929 512 }
3930 else
3931 {
3932 if(!p_igetw(&tempMsgString.nextstring,f))
3933 {
3934 return qe_invalid;
3935 }
3936
3937 if(!pfread(temp_expansion,32,f))
3938 {
3939 return qe_invalid;
3940 }
3941 }
3942
3943
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 MsgStrings[x] = tempMsgString;
3944 512 }
3945 4 }
3946 else
3947 {
3948 int32_t dummy_int;
3949 word s_version;
3950 word s_cversion;
3951
3952 //section version info
3953
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetw(&s_version,f))
3954 {
3955 return qe_invalid;
3956 }
3957
3958 125 FFCore.quest_format[vStrings] = s_version;
3959
3960
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetw(&s_cversion,f))
3961 {
3962 return qe_invalid;
3963 }
3964
3965 //al_trace("Strings version %d\n", s_version);
3966 //section size
3967
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetl(&dummy_int,f))
3968 {
3969 return qe_invalid;
3970 }
3971
3972 //finally... section data
3973
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetw(&temp_msg_count,f))
3974 {
3975 return qe_invalid;
3976 }
3977
3978
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(temp_msg_count >= msg_strings_size)
3979 {
3980 Z_message("Reallocating string buffer...\n");
3981
3982 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3983 // return qe_nomem;
3984 delete[] MsgStrings;
3985 MsgStrings = new MsgStr[MAXMSGS];
3986 msg_strings_size = MAXMSGS;
3987 for(auto q = 0; q < msg_strings_size; ++q)
3988 {
3989 MsgStrings[q].clear();
3990 }
3991 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3992 }
3993
3994 //reset the message strings
3995
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 36 times.
125 if(s_version < 7)
3996
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3997
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 init_msgstrings(0,msg_strings_size);
3998
3999 125 int32_t string_length=(s_version<2)?73:145;
4000
4001
2/2
✓ Branch 0 taken 27031 times.
✓ Branch 1 taken 125 times.
27156 for(int32_t i=0; i<temp_msg_count; i++)
4002 {
4003
1/2
✓ Branch 0 taken 27031 times.
✗ Branch 1 not taken.
27031 init_msgstr(&tempMsgString);
4004 27031 tempMsgString.listpos = i;
4005
2/2
✓ Branch 0 taken 892 times.
✓ Branch 1 taken 26139 times.
27031 if(s_version > 8)
4006 {
4007
2/4
✓ Branch 0 taken 892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 892 times.
✗ Branch 3 not taken.
892 if(!p_igetl(&string_length,f))
4008 {
4009 return qe_invalid;
4010 }
4011 892 }
4012
4013
2/4
✓ Branch 0 taken 27031 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27031 times.
27031 if (string_length < 0 || string_length > 8193)
4014 {
4015 return qe_invalid;
4016 }
4017
4018
2/2
✓ Branch 0 taken 26893 times.
✓ Branch 1 taken 138 times.
27031 if (string_length > 0)
4019 {
4020
2/4
✓ Branch 0 taken 26893 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26893 times.
✗ Branch 3 not taken.
26893 if (!pfread(buf, string_length, f))
4021 {
4022 return qe_invalid;
4023 }
4024 26893 }
4025 else
4026 {
4027 138 buf[0] = 0;
4028 }
4029
4030
2/4
✓ Branch 0 taken 27031 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27031 times.
✗ Branch 3 not taken.
27031 if(!p_igetw(&tempMsgString.nextstring,f))
4031 {
4032 return qe_invalid;
4033 }
4034
4035
2/2
✓ Branch 0 taken 19101 times.
✓ Branch 1 taken 7930 times.
27031 if(s_version<2)
4036 {
4037 19101 buf[72] = '\0';
4038
1/2
✓ Branch 0 taken 19101 times.
✗ Branch 1 not taken.
19101 tempMsgString.s = buf;
4039 19101 }
4040 else
4041 {
4042 // June 2008: A bug corrupted the last 4 chars of a string.
4043 // Discard these.
4044
1/2
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
7930 if(s_version<3)
4045 {
4046 for(int32_t j=140; j<144; j++)
4047 {
4048 buf[j] = '\0';
4049 }
4050 }
4051
1/2
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
7930 if(string_length > 8192) string_length = 8192;
4052 7930 buf[string_length]='\0'; //Force-terminate
4053
1/2
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
7930 tempMsgString.s = buf;
4054
4055
2/2
✓ Branch 0 taken 892 times.
✓ Branch 1 taken 7038 times.
7930 if ( s_version >= 6 )
4056 {
4057
2/4
✓ Branch 0 taken 892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 892 times.
✗ Branch 3 not taken.
892 if(!p_igetl(&tempMsgString.tile,f))
4058 {
4059 return qe_invalid;
4060 }
4061 892 }
4062 else
4063 {
4064
2/4
✓ Branch 0 taken 7038 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7038 times.
✗ Branch 3 not taken.
7038 if(!p_igetw(&tempMsgString.tile,f))
4065 {
4066 return qe_invalid;
4067 }
4068 }
4069
4070
2/4
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7930 times.
✗ Branch 3 not taken.
7930 if(!p_getc(&tempMsgString.cset,f))
4071 {
4072 return qe_invalid;
4073 }
4074
4075 byte dummy_char;
4076
4077
2/4
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7930 times.
✗ Branch 3 not taken.
7930 if(!p_getc(&dummy_char,f)) // trans is stored as a char...
4078 {
4079 return qe_invalid;
4080 }
4081
4082 7930 tempMsgString.trans=dummy_char!=0;
4083
4084
2/4
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7930 times.
✗ Branch 3 not taken.
7930 if(!p_getc(&tempMsgString.font,f))
4085 {
4086 return qe_invalid;
4087 }
4088
4089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7930 times.
7930 if(s_version < 5)
4090 {
4091 if(!p_getc(&tempMsgString.y,f))
4092 {
4093 return qe_invalid;
4094 }
4095 }
4096 else
4097 {
4098
2/4
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7930 times.
✗ Branch 3 not taken.
7930 if(!p_igetw(&tempMsgString.x,f))
4099 {
4100 return qe_invalid;
4101 }
4102
4103
2/4
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7930 times.
✗ Branch 3 not taken.
7930 if(!p_igetw(&tempMsgString.y,f))
4104 {
4105 return qe_invalid;
4106 }
4107
4108
2/4
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7930 times.
✗ Branch 3 not taken.
7930 if(!p_igetw(&tempMsgString.w,f))
4109 {
4110 return qe_invalid;
4111 }
4112
4113
2/4
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7930 times.
✗ Branch 3 not taken.
7930 if(!p_igetw(&tempMsgString.h,f))
4114 {
4115 return qe_invalid;
4116 }
4117
4118
2/4
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7930 times.
✗ Branch 3 not taken.
7930 if(!p_getc(&tempMsgString.hspace,f))
4119 {
4120 return qe_invalid;
4121 }
4122
4123
2/4
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7930 times.
✗ Branch 3 not taken.
7930 if(!p_getc(&tempMsgString.vspace,f))
4124 {
4125 return qe_invalid;
4126 }
4127
4128
2/4
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7930 times.
✗ Branch 3 not taken.
7930 if(!p_getc(&tempMsgString.stringflags,f))
4129 {
4130 return qe_invalid;
4131 }
4132 }
4133
4134
2/2
✓ Branch 0 taken 7038 times.
✓ Branch 1 taken 892 times.
7930 if(s_version >= 7)
4135 {
4136
2/2
✓ Branch 0 taken 892 times.
✓ Branch 1 taken 3568 times.
4460 for(int32_t q = 0; q < 4; ++q)
4137 {
4138
2/4
✓ Branch 0 taken 3568 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3568 times.
✗ Branch 3 not taken.
3568 if(!p_getc(&tempMsgString.margins[q],f))
4139 {
4140 return qe_invalid;
4141 }
4142 3568 }
4143
4144
2/4
✓ Branch 0 taken 892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 892 times.
✗ Branch 3 not taken.
892 if(!p_igetl(&tempMsgString.portrait_tile,f))
4145 {
4146 return qe_invalid;
4147 }
4148
4149
2/4
✓ Branch 0 taken 892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 892 times.
✗ Branch 3 not taken.
892 if(!p_getc(&tempMsgString.portrait_cset,f))
4150 {
4151 return qe_invalid;
4152 }
4153
4154
2/4
✓ Branch 0 taken 892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 892 times.
✗ Branch 3 not taken.
892 if(!p_getc(&tempMsgString.portrait_x,f))
4155 {
4156 return qe_invalid;
4157 }
4158
4159
2/4
✓ Branch 0 taken 892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 892 times.
✗ Branch 3 not taken.
892 if(!p_getc(&tempMsgString.portrait_y,f))
4160 {
4161 return qe_invalid;
4162 }
4163
4164
2/4
✓ Branch 0 taken 892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 892 times.
✗ Branch 3 not taken.
892 if(!p_getc(&tempMsgString.portrait_tw,f))
4165 {
4166 return qe_invalid;
4167 }
4168
4169
2/4
✓ Branch 0 taken 892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 892 times.
✗ Branch 3 not taken.
892 if(!p_getc(&tempMsgString.portrait_th,f))
4170 {
4171 return qe_invalid;
4172 }
4173 892 }
4174
4175
2/2
✓ Branch 0 taken 892 times.
✓ Branch 1 taken 7038 times.
7930 if(s_version >= 8)
4176 {
4177
2/4
✓ Branch 0 taken 892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 892 times.
✗ Branch 3 not taken.
892 if(!p_getc(&tempMsgString.shadow_type,f))
4178 {
4179 return qe_invalid;
4180 }
4181
4182
2/4
✓ Branch 0 taken 892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 892 times.
✗ Branch 3 not taken.
892 if(!p_getc(&tempMsgString.shadow_color,f))
4183 {
4184 return qe_invalid;
4185 }
4186 892 }
4187
4188
2/2
✓ Branch 0 taken 775 times.
✓ Branch 1 taken 7155 times.
7930 if(s_version >= 10)
4189 {
4190
2/4
✓ Branch 0 taken 775 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 775 times.
✗ Branch 3 not taken.
775 if(!p_getc(&tempMsgString.drawlayer,f))
4191 {
4192 return qe_invalid;
4193 }
4194 775 }
4195
4196
2/4
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7930 times.
✗ Branch 3 not taken.
7930 if(!p_getc(&tempMsgString.sfx,f))
4197 {
4198 return qe_invalid;
4199 }
4200
4201
1/2
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
7930 if(s_version>3)
4202 {
4203
2/4
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7930 times.
✗ Branch 3 not taken.
7930 if(!p_igetw(&tempMsgString.listpos,f))
4204 {
4205 return qe_invalid;
4206 }
4207 7930 }
4208 }
4209
4210
1/2
✓ Branch 0 taken 27031 times.
✗ Branch 1 not taken.
27031 MsgStrings[i].copyAll(tempMsgString);
4211 27031 }
4212 }
4213
4214 129 msg_count=temp_msg_count;
4215
4216 129 return 0;
4217 129 }
4218
4219 129 int32_t readdoorcombosets(PACKFILE *f, zquestheader *Header)
4220 {
4221
2/4
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if((Header->zelda_version < 0x192)||
4222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 ((Header->zelda_version == 0x192)&&(Header->build<158)))
4223 {
4224 4 return 0;
4225 }
4226
4227 125 word temp_door_combo_set_count=0;
4228 DoorComboSet tempDoorComboSet;
4229 word dummy_word;
4230 int32_t dummy_long;
4231 byte padding;
4232 125 int32_t s_version = 0;
4233
4234
2/2
✓ Branch 0 taken 32000 times.
✓ Branch 1 taken 125 times.
32125 for(int32_t i=0; i<MAXDOORCOMBOSETS; i++)
4235 {
4236 32000 memset(DoorComboSets+i, 0, sizeof(DoorComboSet));
4237 32000 }
4238
4239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(Header->zelda_version > 0x192)
4240 {
4241 //section version info
4242
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_version,f))
4243 {
4244 return qe_invalid;
4245 }
4246
4247 125 FFCore.quest_format[vDoors] = s_version;
4248
4249 //al_trace("Door combo sets version %d\n", dummy_word);
4250
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&dummy_word,f))
4251 {
4252 return qe_invalid;
4253 }
4254
4255 //section size
4256
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&dummy_long,f))
4257 {
4258 return qe_invalid;
4259 }
4260 125 }
4261
4262 //finally... section data
4263
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&temp_door_combo_set_count,f))
4264 {
4265 return qe_invalid;
4266 }
4267
4268
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
125 if (!(temp_door_combo_set_count >= 0 && temp_door_combo_set_count <= MAXDOORCOMBOSETS))
4269 {
4270 return qe_invalid;
4271 }
4272
4273
2/2
✓ Branch 0 taken 1001 times.
✓ Branch 1 taken 125 times.
1126 for(int32_t i=0; i<temp_door_combo_set_count; i++)
4274 {
4275 1001 memset(&tempDoorComboSet, 0, sizeof(DoorComboSet));
4276
4277 //name
4278
1/2
✓ Branch 0 taken 1001 times.
✗ Branch 1 not taken.
1001 if(!pfread(&tempDoorComboSet.name,sizeof(tempDoorComboSet.name),f))
4279 {
4280 return qe_invalid;
4281 }
4282
4283
1/2
✓ Branch 0 taken 1001 times.
✗ Branch 1 not taken.
1001 if(Header->zelda_version < 0x193)
4284 {
4285 if(!p_getc(&padding,f))
4286 {
4287 return qe_invalid;
4288 }
4289 }
4290
4291 //up door
4292
2/2
✓ Branch 0 taken 9009 times.
✓ Branch 1 taken 1001 times.
10010 for(int32_t j=0; j<9; j++)
4293 {
4294
2/2
✓ Branch 0 taken 36036 times.
✓ Branch 1 taken 9009 times.
45045 for(int32_t k=0; k<4; k++)
4295 {
4296
1/2
✓ Branch 0 taken 36036 times.
✗ Branch 1 not taken.
36036 if(!p_igetw(&tempDoorComboSet.doorcombo_u[j][k],f))
4297 {
4298 return qe_invalid;
4299 }
4300 36036 }
4301 9009 }
4302
4303
2/2
✓ Branch 0 taken 9009 times.
✓ Branch 1 taken 1001 times.
10010 for(int32_t j=0; j<9; j++)
4304 {
4305
2/2
✓ Branch 0 taken 36036 times.
✓ Branch 1 taken 9009 times.
45045 for(int32_t k=0; k<4; k++)
4306 {
4307
1/2
✓ Branch 0 taken 36036 times.
✗ Branch 1 not taken.
36036 if(!p_getc(&tempDoorComboSet.doorcset_u[j][k],f))
4308 {
4309 return qe_invalid;
4310 }
4311 36036 }
4312 9009 }
4313
4314 //down door
4315
2/2
✓ Branch 0 taken 9009 times.
✓ Branch 1 taken 1001 times.
10010 for(int32_t j=0; j<9; j++)
4316 {
4317
2/2
✓ Branch 0 taken 36036 times.
✓ Branch 1 taken 9009 times.
45045 for(int32_t k=0; k<4; k++)
4318 {
4319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36036 times.
36036 if(!p_igetw(&tempDoorComboSet.doorcombo_d[j][k],f))
4320 {
4321 return qe_invalid;
4322 }
4323 36036 }
4324 9009 }
4325
4326
2/2
✓ Branch 0 taken 9009 times.
✓ Branch 1 taken 1001 times.
10010 for(int32_t j=0; j<9; j++)
4327 {
4328
2/2
✓ Branch 0 taken 36036 times.
✓ Branch 1 taken 9009 times.
45045 for(int32_t k=0; k<4; k++)
4329 {
4330
1/2
✓ Branch 0 taken 36036 times.
✗ Branch 1 not taken.
36036 if(!p_getc(&tempDoorComboSet.doorcset_d[j][k],f))
4331 {
4332 return qe_invalid;
4333 }
4334 36036 }
4335 9009 }
4336
4337 //left door
4338
2/2
✓ Branch 0 taken 9009 times.
✓ Branch 1 taken 1001 times.
10010 for(int32_t j=0; j<9; j++)
4339 {
4340
2/2
✓ Branch 0 taken 54054 times.
✓ Branch 1 taken 9009 times.
63063 for(int32_t k=0; k<6; k++)
4341 {
4342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54054 times.
54054 if(!p_igetw(&tempDoorComboSet.doorcombo_l[j][k],f))
4343 {
4344 return qe_invalid;
4345 }
4346 54054 }
4347 9009 }
4348
4349
2/2
✓ Branch 0 taken 9009 times.
✓ Branch 1 taken 1001 times.
10010 for(int32_t j=0; j<9; j++)
4350 {
4351
2/2
✓ Branch 0 taken 54054 times.
✓ Branch 1 taken 9009 times.
63063 for(int32_t k=0; k<6; k++)
4352 {
4353
1/2
✓ Branch 0 taken 54054 times.
✗ Branch 1 not taken.
54054 if(!p_getc(&tempDoorComboSet.doorcset_l[j][k],f))
4354 {
4355 return qe_invalid;
4356 }
4357 54054 }
4358 9009 }
4359
4360 //right door
4361
2/2
✓ Branch 0 taken 9009 times.
✓ Branch 1 taken 1001 times.
10010 for(int32_t j=0; j<9; j++)
4362 {
4363
2/2
✓ Branch 0 taken 54054 times.
✓ Branch 1 taken 9009 times.
63063 for(int32_t k=0; k<6; k++)
4364 {
4365
1/2
✓ Branch 0 taken 54054 times.
✗ Branch 1 not taken.
54054 if(!p_igetw(&tempDoorComboSet.doorcombo_r[j][k],f))
4366 {
4367 return qe_invalid;
4368 }
4369 54054 }
4370 9009 }
4371
4372
2/2
✓ Branch 0 taken 9009 times.
✓ Branch 1 taken 1001 times.
10010 for(int32_t j=0; j<9; j++)
4373 {
4374
2/2
✓ Branch 0 taken 54054 times.
✓ Branch 1 taken 9009 times.
63063 for(int32_t k=0; k<6; k++)
4375 {
4376
1/2
✓ Branch 0 taken 54054 times.
✗ Branch 1 not taken.
54054 if(!p_getc(&tempDoorComboSet.doorcset_r[j][k],f))
4377 {
4378 return qe_invalid;
4379 }
4380 54054 }
4381 9009 }
4382
4383 //up bomb rubble
4384
2/2
✓ Branch 0 taken 2002 times.
✓ Branch 1 taken 1001 times.
3003 for(int32_t j=0; j<2; j++)
4385 {
4386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2002 times.
2002 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_u[j],f))
4387 {
4388 return qe_invalid;
4389 }
4390 2002 }
4391
4392
2/2
✓ Branch 0 taken 2002 times.
✓ Branch 1 taken 1001 times.
3003 for(int32_t j=0; j<2; j++)
4393 {
4394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2002 times.
2002 if(!p_getc(&tempDoorComboSet.bombdoorcset_u[j],f))
4395 {
4396 return qe_invalid;
4397 }
4398 2002 }
4399
4400 //down bomb rubble
4401
2/2
✓ Branch 0 taken 2002 times.
✓ Branch 1 taken 1001 times.
3003 for(int32_t j=0; j<2; j++)
4402 {
4403
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2002 times.
2002 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_d[j],f))
4404 {
4405 return qe_invalid;
4406 }
4407 2002 }
4408
4409
2/2
✓ Branch 0 taken 2002 times.
✓ Branch 1 taken 1001 times.
3003 for(int32_t j=0; j<2; j++)
4410 {
4411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2002 times.
2002 if(!p_getc(&tempDoorComboSet.bombdoorcset_d[j],f))
4412 {
4413 return qe_invalid;
4414 }
4415 2002 }
4416
4417 //left bomb rubble
4418
2/2
✓ Branch 0 taken 3003 times.
✓ Branch 1 taken 1001 times.
4004 for(int32_t j=0; j<3; j++)
4419 {
4420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3003 times.
3003 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_l[j],f))
4421 {
4422 return qe_invalid;
4423 }
4424 3003 }
4425
4426
2/2
✓ Branch 0 taken 3003 times.
✓ Branch 1 taken 1001 times.
4004 for(int32_t j=0; j<3; j++)
4427 {
4428
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3003 times.
3003 if(!p_getc(&tempDoorComboSet.bombdoorcset_l[j],f))
4429 {
4430 return qe_invalid;
4431 }
4432 3003 }
4433
4434
1/2
✓ Branch 0 taken 1001 times.
✗ Branch 1 not taken.
1001 if(Header->zelda_version < 0x193)
4435 {
4436 if(!p_getc(&padding,f))
4437 {
4438 return qe_invalid;
4439 }
4440
4441 }
4442
4443 //right bomb rubble
4444
2/2
✓ Branch 0 taken 3003 times.
✓ Branch 1 taken 1001 times.
4004 for(int32_t j=0; j<3; j++)
4445 {
4446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3003 times.
3003 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_r[j],f))
4447 {
4448 return qe_invalid;
4449 }
4450 3003 }
4451
4452
2/2
✓ Branch 0 taken 3003 times.
✓ Branch 1 taken 1001 times.
4004 for(int32_t j=0; j<3; j++)
4453 {
4454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3003 times.
3003 if(!p_getc(&tempDoorComboSet.bombdoorcset_r[j],f))
4455 {
4456 return qe_invalid;
4457 }
4458 3003 }
4459
4460
1/2
✓ Branch 0 taken 1001 times.
✗ Branch 1 not taken.
1001 if(Header->zelda_version < 0x193)
4461 {
4462 if(!p_getc(&padding,f))
4463 {
4464 return qe_invalid;
4465 }
4466 }
4467
4468 //walkthrough stuff
4469
2/2
✓ Branch 0 taken 4004 times.
✓ Branch 1 taken 1001 times.
5005 for(int32_t j=0; j<4; j++)
4470 {
4471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4004 times.
4004 if(!p_igetw(&tempDoorComboSet.walkthroughcombo[j],f))
4472 {
4473 return qe_invalid;
4474 }
4475 4004 }
4476
4477
2/2
✓ Branch 0 taken 4004 times.
✓ Branch 1 taken 1001 times.
5005 for(int32_t j=0; j<4; j++)
4478 {
4479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4004 times.
4004 if(!p_getc(&tempDoorComboSet.walkthroughcset[j],f))
4480 {
4481 return qe_invalid;
4482 }
4483 4004 }
4484
4485 //flags
4486
2/2
✓ Branch 0 taken 2002 times.
✓ Branch 1 taken 1001 times.
3003 for(int32_t j=0; j<2; j++)
4487 {
4488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2002 times.
2002 if(!p_getc(&tempDoorComboSet.flags[j],f))
4489 {
4490 return qe_invalid;
4491 }
4492 2002 }
4493
4494
1/2
✓ Branch 0 taken 1001 times.
✗ Branch 1 not taken.
1001 if(Header->zelda_version < 0x193)
4495 {
4496 if(!pfread(&tempDoorComboSet.expansion,sizeof(tempDoorComboSet.expansion),f))
4497 {
4498 return qe_invalid;
4499 }
4500 }
4501
4502 1001 memcpy(&DoorComboSets[i], &tempDoorComboSet, sizeof(tempDoorComboSet));
4503 1001 }
4504
4505 125 door_combo_set_count=temp_door_combo_set_count;
4506
4507 125 return 0;
4508 129 }
4509
4510 int32_t count_dmaps()
4511 {
4512 int32_t i=MAXDMAPS-1;
4513 bool found=false;
4514
4515 while(i>=0 && !found)
4516 {
4517 if((DMaps[i].map!=0)||(DMaps[i].level!=0)||(DMaps[i].xoff!=0)||
4518 (DMaps[i].compass!=0)||(DMaps[i].color!=0)||(DMaps[i].midi!=0)||
4519 (DMaps[i].cont!=0)||(DMaps[i].type!=0))
4520 found=true;
4521
4522 for(int32_t j=0; j<8; j++)
4523 {
4524 if(DMaps[i].grid[j]!=0)
4525
4526 found=true;
4527 }
4528
4529 if((DMaps[i].name[0]!=0)||(DMaps[i].title[0]!=0)||
4530 (DMaps[i].intro[0]!=0)||(DMaps[i].tmusic[0]!=0))
4531 found=true;
4532
4533 if((DMaps[i].minimap_1_tile!=0)||(DMaps[i].minimap_2_tile!=0)||
4534 (DMaps[i].largemap_1_tile!=0)||(DMaps[i].largemap_2_tile!=0)||
4535 (DMaps[i].minimap_1_cset!=0)||(DMaps[i].minimap_2_cset!=0)||
4536 (DMaps[i].largemap_1_cset!=0)||(DMaps[i].largemap_2_cset!=0))
4537 found=true;
4538
4539 if(!found)
4540 {
4541 i--;
4542 }
4543 }
4544
4545 return i+1;
4546 }
4547
4548
4549 int32_t count_shops(miscQdata *Misc)
4550 {
4551 int32_t i=NUM_SHOPS-1,j;
4552 bool found=false;
4553
4554 while(i>=0 && !found)
4555 {
4556 j=2;
4557
4558 while(j>=0 && !found)
4559 {
4560 if((Misc->shop[i].hasitem[j]!=0)||(Misc->shop[i].price[j]!=0))
4561 {
4562 found=true;
4563 }
4564 else
4565 {
4566 j--;
4567 }
4568 }
4569
4570 if(Misc->shop[i].name[0]!=0)
4571 {
4572 found=true;
4573 }
4574
4575 if(!found)
4576 {
4577 i--;
4578 }
4579 }
4580
4581 return i+1;
4582 }
4583
4584 int32_t count_infos(miscQdata *Misc)
4585 {
4586 int32_t i=255,j;
4587 bool found=false;
4588
4589 while(i>=0 && !found)
4590 {
4591 j=2;
4592
4593 while(j>=0 && !found)
4594 {
4595 if((Misc->info[i].str[j]!=0)||(Misc->info[i].price[j]!=0))
4596 {
4597 found=true;
4598 }
4599 else
4600 {
4601 j--;
4602 }
4603 }
4604
4605 if(Misc->info[i].name[0]!=0)
4606 {
4607 found=true;
4608 }
4609
4610 if(!found)
4611 {
4612 i--;
4613 }
4614 }
4615
4616 return i+1;
4617 }
4618
4619 int32_t count_warprings(miscQdata *Misc)
4620 {
4621 int32_t i=15,j;
4622 bool found=false;
4623
4624 while(i>=0 && !found)
4625 {
4626 j=7;
4627
4628 while(j>=0 && !found)
4629 {
4630 if((Misc->warp[i].dmap[j]!=0)||(Misc->warp[i].scr[j]!=0))
4631 {
4632 found=true;
4633 }
4634 else
4635 {
4636 j--;
4637 }
4638 }
4639
4640 if(!found)
4641 {
4642 i--;
4643 }
4644 }
4645
4646 return i+1;
4647 }
4648
4649 int32_t count_palcycles(miscQdata *Misc)
4650 {
4651 int32_t i=255,j;
4652 bool found=false;
4653
4654 while(i>=0 && !found)
4655 {
4656 j=2;
4657
4658 while(j>=0 && !found)
4659 {
4660 if(Misc->cycles[i][j].count!=0)
4661 {
4662 found=true;
4663 }
4664 else
4665 {
4666 j--;
4667 }
4668 }
4669
4670 if(!found)
4671 {
4672 i--;
4673 }
4674 }
4675
4676 return i+1;
4677 }
4678
4679 264713 void clear_screen(mapscr *temp_scr)
4680 {
4681 264713 temp_scr->zero_memory();
4682 264713 }
4683
4684 129 int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap, word max_dmaps)
4685 {
4686 129 word dmapstoread=0;
4687 dmap tempDMap;
4688
4689 int32_t dummy;
4690 129 word s_version=0, s_cversion=0;
4691 byte padding;
4692
4693
2/2
✓ Branch 0 taken 66048 times.
✓ Branch 1 taken 129 times.
66177 for(int32_t i=0; i<max_dmaps; i++)
4694 {
4695 66048 memset(&DMaps[start_dmap+i],0,sizeof(dmap));
4696 66048 sprintf(DMaps[start_dmap+i].title," ");
4697 66048 sprintf(DMaps[start_dmap+i].intro," ");
4698 66048 DMaps[start_dmap+i].type |= dmCAVE;
4699 66048 }
4700
4701
3/4
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✓ Branch 3 taken 4 times.
129 if(!Header || Header->zelda_version > 0x192)
4702 {
4703 //section version info
4704
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_version,f))
4705 {
4706 return qe_invalid;
4707 }
4708
4709 125 FFCore.quest_format[vDMaps] = s_version;
4710
4711 //al_trace("DMaps version %d\n", s_version);
4712
4713
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_cversion,f))
4714 {
4715 return qe_invalid;
4716 }
4717
4718 //section size
4719
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&dummy,f))
4720 {
4721 return qe_invalid;
4722 }
4723
4724 //finally... section data
4725
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&dmapstoread,f))
4726 {
4727 return qe_invalid;
4728 }
4729 125 }
4730 else
4731 {
4732
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
4733 ((Header->zelda_version == 0x192)&&(Header->build<5)))
4734 {
4735 4 dmapstoread=32;
4736 4 }
4737 else if(s_version <= 4)
4738 {
4739 dmapstoread=OLDMAXDMAPS;
4740 }
4741 else
4742 {
4743 dmapstoread=MAXDMAPS;
4744 }
4745 }
4746
4747
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 113 times.
129 dmapstoread=zc_min(dmapstoread, max_dmaps);
4748
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 113 times.
129 dmapstoread=zc_min(dmapstoread, MAXDMAPS-start_dmap);
4749
4750
2/2
✓ Branch 0 taken 61056 times.
✓ Branch 1 taken 129 times.
61185 for(int32_t i=start_dmap; i<dmapstoread+start_dmap; i++)
4751 {
4752 61056 memset(&tempDMap,0,sizeof(dmap));
4753 61056 sprintf(tempDMap.title," ");
4754 61056 sprintf(tempDMap.intro," ");
4755
4756
1/2
✓ Branch 0 taken 61056 times.
✗ Branch 1 not taken.
61056 if(!p_getc(&tempDMap.map,f))
4757 {
4758 return qe_invalid;
4759 }
4760
4761
2/2
✓ Branch 0 taken 3200 times.
✓ Branch 1 taken 57856 times.
61056 if(s_version <= 4)
4762 {
4763 byte tempbyte;
4764
4765
1/2
✓ Branch 0 taken 3200 times.
✗ Branch 1 not taken.
3200 if(!p_getc(&tempbyte,f))
4766 {
4767 return qe_invalid;
4768 }
4769
4770 3200 tempDMap.level=(word)tempbyte;
4771 3200 }
4772 else
4773 {
4774
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&tempDMap.level,f))
4775 {
4776 return qe_invalid;
4777 }
4778 }
4779
4780
1/2
✓ Branch 0 taken 61056 times.
✗ Branch 1 not taken.
61056 if(!p_getc(&tempDMap.xoff,f))
4781 {
4782 return qe_invalid;
4783 }
4784
4785
1/2
✓ Branch 0 taken 61056 times.
✗ Branch 1 not taken.
61056 if(!p_getc(&tempDMap.compass,f))
4786 {
4787 return qe_invalid;
4788 }
4789
4790
2/2
✓ Branch 0 taken 57856 times.
✓ Branch 1 taken 3200 times.
61056 if(s_version > 8) // February 2009
4791 {
4792
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&tempDMap.color,f))
4793 {
4794 return qe_invalid;
4795 }
4796 57856 }
4797 else
4798 {
4799 byte tempbyte;
4800
4801
1/2
✓ Branch 0 taken 3200 times.
✗ Branch 1 not taken.
3200 if(!p_getc(&tempbyte,f))
4802 {
4803 return qe_invalid;
4804 }
4805
4806 3200 tempDMap.color = (word)tempbyte;
4807 }
4808
4809
1/2
✓ Branch 0 taken 61056 times.
✗ Branch 1 not taken.
61056 if(!p_getc(&tempDMap.midi,f))
4810 {
4811 return qe_invalid;
4812 }
4813
4814
1/2
✓ Branch 0 taken 61056 times.
✗ Branch 1 not taken.
61056 if(!p_getc(&tempDMap.cont,f))
4815 {
4816 return qe_invalid;
4817 }
4818
4819
1/2
✓ Branch 0 taken 61056 times.
✗ Branch 1 not taken.
61056 if(!p_getc(&tempDMap.type,f))
4820 {
4821 return qe_invalid;
4822 }
4823
4824
4/4
✓ Branch 0 taken 830 times.
✓ Branch 1 taken 60226 times.
✓ Branch 2 taken 818 times.
✓ Branch 3 taken 12 times.
61886 if((tempDMap.type & dmfTYPE) == dmOVERW &&
4825
1/2
✓ Branch 0 taken 830 times.
✗ Branch 1 not taken.
830 (!Header || Header->zelda_version >= 0x210)) // Not sure exactly when this changed
4826 818 tempDMap.xoff = 0;
4827
4828
2/2
✓ Branch 0 taken 488448 times.
✓ Branch 1 taken 61056 times.
549504 for(int32_t j=0; j<8; j++)
4829 {
4830
1/2
✓ Branch 0 taken 488448 times.
✗ Branch 1 not taken.
488448 if(!p_getc(&tempDMap.grid[j],f))
4831 {
4832 return qe_invalid;
4833 }
4834 488448 }
4835
4836
4/8
✓ Branch 0 taken 61056 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60928 times.
✓ Branch 3 taken 128 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 60928 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
61056 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<41))))
4837 {
4838
3/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 90 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38 times.
128 if(tempDMap.level>0&&tempDMap.level<10)
4839 {
4840 38 sprintf(tempDMap.title,"LEVEL-%d ", tempDMap.level);
4841 38 }
4842
4843
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
128 if(i==0 && Header->zelda_version <= 0x190)
4844 {
4845 4 tempDMap.cont-=tempDMap.xoff;
4846 4 tempDMap.compass-=tempDMap.xoff;
4847 4 }
4848
4849 //forgotten -DD
4850
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 90 times.
128 if(tempDMap.level==0)
4851 {
4852 90 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4853 90 }
4854 128 }
4855 else
4856 {
4857
1/2
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
60928 if(!pfread(&tempDMap.name,sizeof(DMaps[0].name),f))
4858 {
4859 return qe_invalid;
4860 }
4861
4862
1/2
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
60928 if(!pfread(&tempDMap.title,sizeof(DMaps[0].title),f))
4863 {
4864 return qe_invalid;
4865 }
4866
4867
1/2
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
60928 if(!pfread(&tempDMap.intro,sizeof(DMaps[0].intro),f))
4868 {
4869 return qe_invalid;
4870 }
4871
4872
3/8
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60928 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 60928 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
60928 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<152))))
4873 {
4874 if ((tempDMap.type & dmfTYPE) == dmOVERW) tempDMap.flags = dmfCAVES | dmf3STAIR | dmfWHIRLWIND | dmfGUYCAVES;
4875 memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap));
4876
4877 continue;
4878 }
4879
4880
2/4
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60928 times.
✗ Branch 3 not taken.
60928 if(Header && (Header->zelda_version < 0x193))
4881 {
4882 if(!p_getc(&padding,f))
4883 {
4884 return qe_invalid;
4885 }
4886 }
4887
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 42496 times.
60928 if ( s_version >= 11 )
4888 {
4889
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&tempDMap.minimap_1_tile,f))
4890 {
4891 return qe_invalid;
4892 }
4893 18432 }
4894 else
4895 {
4896
1/2
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
42496 if(!p_igetw(&tempDMap.minimap_1_tile,f))
4897 {
4898 return qe_invalid;
4899 }
4900 }
4901
4902
1/2
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
60928 if(!p_getc(&tempDMap.minimap_1_cset,f))
4903 {
4904 return qe_invalid;
4905 }
4906
4907
2/4
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60928 times.
✗ Branch 3 not taken.
60928 if(Header && (Header->zelda_version < 0x193))
4908 {
4909 if(!p_getc(&padding,f))
4910 {
4911 return qe_invalid;
4912 }
4913 }
4914
4915
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 42496 times.
60928 if ( s_version >= 11 )
4916 {
4917
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&tempDMap.minimap_2_tile,f))
4918 {
4919 return qe_invalid;
4920 }
4921 18432 }
4922 else
4923 {
4924
1/2
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
42496 if(!p_igetw(&tempDMap.minimap_2_tile,f))
4925 {
4926 return qe_invalid;
4927 }
4928 }
4929
1/2
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
60928 if(!p_getc(&tempDMap.minimap_2_cset,f))
4930 {
4931 return qe_invalid;
4932 }
4933
4934
2/4
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60928 times.
✗ Branch 3 not taken.
60928 if(Header && (Header->zelda_version < 0x193))
4935 {
4936 if(!p_getc(&padding,f))
4937 {
4938 return qe_invalid;
4939 }
4940 }
4941
4942
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 42496 times.
60928 if ( s_version >= 11 )
4943 {
4944
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&tempDMap.largemap_1_tile,f))
4945 {
4946 return qe_invalid;
4947 }
4948 18432 }
4949 else
4950 {
4951
1/2
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
42496 if(!p_igetw(&tempDMap.largemap_1_tile,f))
4952 {
4953 return qe_invalid;
4954 }
4955 }
4956
4957
1/2
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
60928 if(!p_getc(&tempDMap.largemap_1_cset,f))
4958 {
4959 return qe_invalid;
4960 }
4961
4962
2/4
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60928 times.
✗ Branch 3 not taken.
60928 if(Header && (Header->zelda_version < 0x193))
4963 {
4964
4965 if(!p_getc(&padding,f))
4966 {
4967 return qe_invalid;
4968 }
4969 }
4970
4971
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 42496 times.
60928 if ( s_version >= 11 )
4972 {
4973
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&tempDMap.largemap_2_tile,f))
4974 {
4975 return qe_invalid;
4976 }
4977 18432 }
4978 else
4979 {
4980
1/2
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
42496 if(!p_igetw(&tempDMap.largemap_2_tile,f))
4981 {
4982 return qe_invalid;
4983 }
4984 }
4985
1/2
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
60928 if(!p_getc(&tempDMap.largemap_2_cset,f))
4986 {
4987 return qe_invalid;
4988 }
4989
4990
1/2
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
60928 if(!pfread(&tempDMap.tmusic,sizeof(DMaps[0].tmusic),f))
4991 {
4992 return qe_invalid;
4993 }
4994 }
4995
4996
2/2
✓ Branch 0 taken 3200 times.
✓ Branch 1 taken 57856 times.
61056 if(s_version>1)
4997 {
4998
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&tempDMap.tmusictrack,f))
4999 {
5000 return qe_invalid;
5001 }
5002
5003
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&tempDMap.active_subscreen,f))
5004 {
5005 return qe_invalid;
5006 }
5007
5008
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&tempDMap.passive_subscreen,f))
5009 {
5010 return qe_invalid;
5011 }
5012 57856 }
5013
5014
2/2
✓ Branch 0 taken 3200 times.
✓ Branch 1 taken 57856 times.
61056 if(s_version>2)
5015 {
5016 byte di[32];
5017
5018
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!pfread(&di, 32, f)) return qe_invalid;
5019
5020
2/2
✓ Branch 0 taken 14811136 times.
✓ Branch 1 taken 57856 times.
14868992 for(int32_t j=0; j<MAXITEMS; j++)
5021 {
5022
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 14811129 times.
14811136 if(di[j/8] & (1 << (j%8))) tempDMap.disableditems[j]=1;
5023 14811129 else tempDMap.disableditems[j]=0;
5024 14811136 }
5025 57856 }
5026
5027
2/2
✓ Branch 0 taken 57856 times.
✓ Branch 1 taken 3200 times.
61056 if(s_version >= 6)
5028 {
5029
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&tempDMap.flags,f))
5030 {
5031 return qe_invalid;
5032 }
5033 57856 }
5034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3200 times.
3200 else if(s_version>3)
5035 {
5036 char temp;
5037
5038 if(!p_getc(&temp,f))
5039 {
5040 return qe_invalid;
5041 }
5042
5043 tempDMap.flags = temp;
5044 }
5045
3/8
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 2384 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 816 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3200 else if(tempDMap.level==0 && ((Header->zelda_version < 0x211) || ((Header->zelda_version == 0x211) && (Header->build<18))))
5046 {
5047 816 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
5048 816 }
5049 else
5050 2384 tempDMap.flags=0;
5051
5052
2/2
✓ Branch 0 taken 57856 times.
✓ Branch 1 taken 3200 times.
61056 if(s_version<7)
5053 {
5054
3/4
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 2384 times.
✓ Branch 2 taken 816 times.
✗ Branch 3 not taken.
3200 if(tempDMap.level==0 && get_bit(deprecated_rules,14))
5055 816 tempDMap.flags|= dmfVIEWMAP;
5056 3200 }
5057
5058
2/2
✓ Branch 0 taken 57856 times.
✓ Branch 1 taken 3200 times.
61056 if(s_version<8)
5059 {
5060
4/4
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 2384 times.
✓ Branch 2 taken 207 times.
✓ Branch 3 taken 609 times.
3200 if(tempDMap.level==0 && (tempDMap.type&dmfTYPE)==dmDNGN)
5061 {
5062 609 tempDMap.type &= ~dmDNGN;
5063 609 tempDMap.type |= dmCAVE;
5064 609 }
5065
2/2
✓ Branch 0 taken 855 times.
✓ Branch 1 taken 1736 times.
2591 else if((tempDMap.type&dmfTYPE)==dmCAVE)
5066 {
5067 1736 tempDMap.flags |= dmfMINIMAPCOLORFIX;
5068 1736 }
5069 3200 }
5070
5071
5/8
✓ Branch 0 taken 61056 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 60928 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 128 times.
✓ Branch 6 taken 60928 times.
✗ Branch 7 not taken.
61056 if(Header && ((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>=41)))
5072 60928 && (Header->zelda_version < 0x193))
5073 {
5074 if(!p_getc(&padding,f))
5075 {
5076 return qe_invalid;
5077 }
5078 }
5079
5080
2/2
✓ Branch 0 taken 42624 times.
✓ Branch 1 taken 18432 times.
61056 if(s_version >= 10)
5081 {
5082
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_getc(&tempDMap.sideview,f))
5083 {
5084 return qe_invalid;
5085 }
5086 18432 }
5087
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 42624 times.
61056 if(s_version < 10) tempDMap.sideview = 0;
5088
5089 //Dmap Scripts
5090
2/2
✓ Branch 0 taken 42624 times.
✓ Branch 1 taken 18432 times.
61056 if(s_version >= 12)
5091 {
5092
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetw(&tempDMap.script,f))
5093 {
5094 return qe_invalid;
5095 }
5096
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 18432 times.
165888 for ( int32_t q = 0; q < 8; q++ )
5097 {
5098
1/2
✓ Branch 0 taken 147456 times.
✗ Branch 1 not taken.
147456 if(!p_igetl(&tempDMap.initD[q],f))
5099 {
5100 return qe_invalid;
5101 }
5102 147456 }
5103 18432 }
5104
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 42624 times.
61056 if ( s_version < 12 )
5105 {
5106 42624 tempDMap.script = 0;
5107
2/2
✓ Branch 0 taken 340992 times.
✓ Branch 1 taken 42624 times.
383616 for ( int32_t q = 0; q < 8; q++ )
5108 {
5109 340992 tempDMap.initD[q] = 0;
5110 340992 }
5111 42624 }
5112
5113
2/2
✓ Branch 0 taken 42624 times.
✓ Branch 1 taken 18432 times.
61056 if(s_version >= 13)
5114 {
5115
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 18432 times.
165888 for ( int32_t q = 0; q < 8; q++ )
5116 {
5117
2/2
✓ Branch 0 taken 9584640 times.
✓ Branch 1 taken 147456 times.
9732096 for ( int32_t w = 0; w < 65; w++ )
5118 {
5119
1/2
✓ Branch 0 taken 9584640 times.
✗ Branch 1 not taken.
9584640 if(!p_getc(&tempDMap.initD_label[q][w],f))
5120 {
5121 return qe_invalid;
5122 }
5123 9584640 }
5124 147456 }
5125 18432 }
5126
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 42624 times.
61056 if ( s_version < 13 )
5127 {
5128 42624 tempDMap.script = 0;
5129
2/2
✓ Branch 0 taken 340992 times.
✓ Branch 1 taken 42624 times.
383616 for ( int32_t q = 0; q < 8; q++ )
5130 {
5131
2/2
✓ Branch 0 taken 22164480 times.
✓ Branch 1 taken 340992 times.
22505472 for ( int32_t w = 0; w < 65; w++ )
5132 22164480 tempDMap.initD_label[q][w] = 0;
5133 340992 }
5134 42624 }
5135
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 42624 times.
61056 if(s_version >= 14)
5136 {
5137
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetw(&tempDMap.active_sub_script,f))
5138 {
5139 return qe_invalid;
5140 }
5141
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetw(&tempDMap.passive_sub_script,f))
5142 {
5143 return qe_invalid;
5144 }
5145
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 18432 times.
165888 for ( int32_t q = 0; q < 8; ++q )
5146 {
5147
1/2
✓ Branch 0 taken 147456 times.
✗ Branch 1 not taken.
147456 if(!p_igetl(&tempDMap.sub_initD[q],f))
5148 {
5149 return qe_invalid;
5150 }
5151 147456 }
5152
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 18432 times.
165888 for(int32_t q = 0; q < 8; ++q)
5153 {
5154
2/2
✓ Branch 0 taken 9584640 times.
✓ Branch 1 taken 147456 times.
9732096 for ( int32_t w = 0; w < 65; ++w )
5155 {
5156
1/2
✓ Branch 0 taken 9584640 times.
✗ Branch 1 not taken.
9584640 if(!p_getc(&tempDMap.sub_initD_label[q][w],f))
5157 {
5158 return qe_invalid;
5159 }
5160 9584640 }
5161 147456 }
5162 18432 }
5163 else
5164 {
5165 42624 tempDMap.active_sub_script = 0;
5166 42624 tempDMap.passive_sub_script = 0;
5167
2/2
✓ Branch 0 taken 340992 times.
✓ Branch 1 taken 42624 times.
383616 for(int32_t q = 0; q < 8; ++q)
5168 {
5169 340992 tempDMap.sub_initD[q] = 0;
5170
2/2
✓ Branch 0 taken 22164480 times.
✓ Branch 1 taken 340992 times.
22505472 for(int32_t w = 0; w < 65; ++w)
5171 22164480 tempDMap.sub_initD_label[q][w] = 0;
5172 340992 }
5173 }
5174
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 42624 times.
61056 if(s_version >= 15)
5175 {
5176
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetw(&tempDMap.onmap_script,f))
5177 {
5178 return qe_invalid;
5179 }
5180
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 18432 times.
165888 for ( int32_t q = 0; q < 8; ++q )
5181 {
5182
1/2
✓ Branch 0 taken 147456 times.
✗ Branch 1 not taken.
147456 if(!p_igetl(&tempDMap.onmap_initD[q],f))
5183 {
5184 return qe_invalid;
5185 }
5186 147456 }
5187
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 18432 times.
165888 for(int32_t q = 0; q < 8; ++q)
5188 {
5189
2/2
✓ Branch 0 taken 9584640 times.
✓ Branch 1 taken 147456 times.
9732096 for ( int32_t w = 0; w < 65; ++w )
5190 {
5191
1/2
✓ Branch 0 taken 9584640 times.
✗ Branch 1 not taken.
9584640 if(!p_getc(&tempDMap.onmap_initD_label[q][w],f))
5192 {
5193 return qe_invalid;
5194 }
5195 9584640 }
5196 147456 }
5197 18432 }
5198 else
5199 {
5200 42624 tempDMap.onmap_script = 0;
5201
2/2
✓ Branch 0 taken 340992 times.
✓ Branch 1 taken 42624 times.
383616 for(int32_t q = 0; q < 8; ++q)
5202 {
5203 340992 tempDMap.onmap_initD[q] = 0;
5204
2/2
✓ Branch 0 taken 22164480 times.
✓ Branch 1 taken 340992 times.
22505472 for(int32_t w = 0; w < 65; ++w)
5205 {
5206 22164480 tempDMap.onmap_initD_label[q][w] = 0;
5207 22164480 }
5208 340992 }
5209 }
5210
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 42624 times.
61056 if(s_version >= 16)
5211 {
5212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18432 times.
18432 if(!p_igetw(&tempDMap.mirrorDMap,f))
5213 {
5214 return qe_invalid;
5215 }
5216 18432 }
5217 else
5218 {
5219 42624 tempDMap.mirrorDMap = -1;
5220 }
5221
5222
2/2
✓ Branch 0 taken 51328 times.
✓ Branch 1 taken 9728 times.
61056 if(s_version >= 17)
5223 {
5224 // Reserved for z3.
5225 9728 }
5226
5227 61056 memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap));
5228 61056 }
5229
5230 129 return 0;
5231 129 }
5232
5233 113 int32_t readmisccolors(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5234 {
5235 //these are here to bypass compiler warnings about unused arguments
5236 113 Header=Header;
5237
5238 miscQdata temp_misc;
5239 113 word s_version=0, s_cversion=0;
5240 113 int32_t tempsize=0;
5241 word dummyw;
5242
5243 113 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5244
5245 //section version info
5246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(!p_igetw(&s_version,f))
5247 {
5248 return qe_invalid;
5249 }
5250
5251 113 FFCore.quest_format[vColours] = s_version;
5252
5253 113 al_trace("Misc Colours section version: %d\n", s_version);
5254
5255 //al_trace("Misc. colors version %d\n", s_version);
5256
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&s_cversion,f))
5257 {
5258 return qe_invalid;
5259 }
5260
5261
5262 //section size
5263
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetl(&tempsize,f))
5264 {
5265 return qe_invalid;
5266 }
5267
5268 //finally... section data
5269 113 readsize=0;
5270
5271
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.text,f))
5272 {
5273 return qe_invalid;
5274 }
5275
5276
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.caption,f))
5277 {
5278 return qe_invalid;
5279 }
5280
5281
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.overw_bg,f))
5282 {
5283 return qe_invalid;
5284 }
5285
5286
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5287 {
5288 return qe_invalid;
5289 }
5290
5291
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5292 {
5293 return qe_invalid;
5294 }
5295
5296
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.cave_fg,f))
5297 {
5298 return qe_invalid;
5299 }
5300
5301
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.bs_dk,f))
5302 {
5303 return qe_invalid;
5304 }
5305
5306
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.bs_goal,f))
5307 {
5308 return qe_invalid;
5309 }
5310
5311
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.compass_lt,f))
5312 {
5313 return qe_invalid;
5314 }
5315
5316
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.compass_dk,f))
5317 {
5318 return qe_invalid;
5319 }
5320
5321
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5322 {
5323 return qe_invalid;
5324 }
5325
5326
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.triframe_color,f))
5327 {
5328 return qe_invalid;
5329 }
5330
5331
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.hero_dot,f))
5332 {
5333 return qe_invalid;
5334 }
5335
5336
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5337 {
5338 return qe_invalid;
5339 }
5340
5341
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5342 {
5343 return qe_invalid;
5344 }
5345
5346
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5347 {
5348 return qe_invalid;
5349 }
5350
5351
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5352 {
5353 return qe_invalid;
5354 }
5355
5356
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5357 {
5358 return qe_invalid;
5359 }
5360
5361
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5362 {
5363 return qe_invalid;
5364 }
5365
5366
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5367 {
5368 return qe_invalid;
5369 }
5370
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 77 times.
113 if(s_version < 4)
5371 {
5372
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5373 return qe_invalid;
5374 77 temp_misc.colors.triforce_tile = dummyw;
5375
5376
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5377 return qe_invalid;
5378 77 temp_misc.colors.triframe_tile = dummyw;
5379
5380
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5381 return qe_invalid;
5382 77 temp_misc.colors.overworld_map_tile = dummyw;
5383
5384
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5385 return qe_invalid;
5386 77 temp_misc.colors.dungeon_map_tile = dummyw;
5387
5388
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5389 return qe_invalid;
5390 77 temp_misc.colors.blueframe_tile = dummyw;
5391
5392
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5393 return qe_invalid;
5394 77 temp_misc.colors.HCpieces_tile = dummyw;
5395 77 }
5396
5397
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
5398 {
5399 return qe_invalid;
5400 }
5401
5402
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
5403 {
5404 return qe_invalid;
5405 }
5406
5407
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(s_version < 2)
5408 {
5409 temp_misc.colors.msgtext = 0x01;
5410 }
5411 else
5412 {
5413
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.msgtext, f))
5414 {
5415 return qe_invalid;
5416 }
5417 }
5418
5419
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 36 times.
113 if ( s_version >= 3 ) //expanded tile pages to 825
5420 {
5421
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&temp_misc.colors.triforce_tile,f))
5422 {
5423 return qe_invalid;
5424 }
5425
5426
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&temp_misc.colors.triframe_tile,f))
5427 {
5428 return qe_invalid;
5429 }
5430
5431
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&temp_misc.colors.overworld_map_tile,f))
5432 {
5433 return qe_invalid;
5434 }
5435
5436
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&temp_misc.colors.dungeon_map_tile,f))
5437 {
5438 return qe_invalid;
5439 }
5440
5441
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&temp_misc.colors.blueframe_tile,f))
5442 {
5443 return qe_invalid;
5444 }
5445
5446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(!p_igetl(&temp_misc.colors.HCpieces_tile,f))
5447 {
5448 return qe_invalid;
5449 }
5450 36 }
5451
5452 113 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5453
5454 113 return 0;
5455 113 }
5456
5457 113 int32_t readgameicons(PACKFILE *f, zquestheader *, miscQdata *Misc)
5458 {
5459 miscQdata temp_misc;
5460 113 word s_version=0, s_cversion=0;
5461 byte icons;
5462 113 int32_t tempsize=0;
5463
5464 113 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5465
5466 //section version info
5467
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(!p_igetw(&s_version,f))
5468 {
5469 return qe_invalid;
5470 }
5471
5472 113 FFCore.quest_format[vIcons] = s_version;
5473
5474 //al_trace("Game icons version %d\n", s_version);
5475
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&s_cversion,f))
5476 {
5477 return qe_invalid;
5478 }
5479
5480
5481 //section size
5482
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetl(&tempsize,f))
5483 {
5484 return qe_invalid;
5485 }
5486
5487 //finally... section data
5488 113 readsize=0;
5489
5490 113 icons=4;
5491
5492
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 77 times.
113 if ( s_version >= 10 )
5493 {
5494
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t i=0; i<icons; i++)
5495 {
5496
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_igetl(&temp_misc.icons[i],f))
5497 {
5498 return qe_invalid;
5499 }
5500 144 }
5501 36 }
5502 else
5503 {
5504
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<icons; i++)
5505 {
5506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 308 times.
308 if(!p_igetw(&temp_misc.icons[i],f))
5507 {
5508 return qe_invalid;
5509 }
5510 308 }
5511 }
5512
5513 113 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5514
5515 113 return 0;
5516 113 }
5517
5518 129 int32_t readmisc(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5519 {
5520 129 word maxinfos=256;
5521 129 word maxshops=256;
5522 129 word shops=16, infos=16, warprings=8, palcycles=256, windwarps=9, triforces=8, icons=4;
5523 129 word ponds=16, pondsize=72, expansionsize=98*2;
5524 byte tempbyte, padding;
5525 miscQdata temp_misc;
5526 129 word s_version=0, s_cversion=0;
5527 word swaptmp;
5528 129 int32_t tempsize=0;
5529
5530 129 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5531
5532
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<maxshops; ++i)
5533 {
5534 33024 memset(&temp_misc.shop, 0, sizeof(shoptype)*256);
5535 33024 }
5536
5537
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<maxinfos; ++i)
5538 {
5539 33024 memset(&temp_misc.info, 0, sizeof(infotype)*256);
5540 33024 }
5541
5542
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(Header->zelda_version > 0x192)
5543 {
5544 //section version info
5545
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_version,f))
5546 {
5547 return qe_invalid;
5548 }
5549
5550 125 FFCore.quest_format[vMisc] = s_version;
5551
5552 //al_trace("Misc. data version %d\n", s_version);
5553
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_cversion,f))
5554 {
5555 return qe_invalid;
5556 }
5557
5558
5559 //section size
5560
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&tempsize,f))
5561 {
5562 return qe_invalid;
5563 }
5564 125 }
5565
5566 //finally... section data
5567 129 readsize=0;
5568
5569 //shops
5570
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(Header->zelda_version > 0x192)
5571 {
5572
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&shops,f))
5573 {
5574 return qe_invalid;
5575 }
5576 125 }
5577
5578
2/4
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 129 times.
129 if (!(shops >= 0 && shops <= NUM_SHOPS))
5579 {
5580 return qe_invalid;
5581 }
5582
5583
2/2
✓ Branch 0 taken 1456 times.
✓ Branch 1 taken 129 times.
1585 for(int32_t i=0; i<shops; i++)
5584 {
5585
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 1233 times.
1456 if(s_version > 6)
5586 {
5587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1233 times.
1233 if(!pfread(temp_misc.shop[i].name,sizeof(temp_misc.shop[i].name),f))
5588 {
5589 return qe_invalid;
5590 }
5591 1233 }
5592
5593
2/2
✓ Branch 0 taken 4368 times.
✓ Branch 1 taken 1456 times.
5824 for(int32_t j=0; j<3; j++)
5594 {
5595
1/2
✓ Branch 0 taken 4368 times.
✗ Branch 1 not taken.
4368 if(!p_getc(&temp_misc.shop[i].item[j],f))
5596 {
5597 return qe_invalid;
5598 }
5599
5600
2/2
✓ Branch 0 taken 3699 times.
✓ Branch 1 taken 669 times.
4368 if(s_version < 4)
5601 {
5602 669 temp_misc.shop[i].hasitem[j] = (temp_misc.shop[i].item[j] == 0) ? 0 : 1;
5603 669 }
5604 4368 }
5605
5606
2/2
✓ Branch 0 taken 1392 times.
✓ Branch 1 taken 64 times.
1456 if(Header->zelda_version < 0x193)
5607 {
5608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(!p_getc(&tempbyte,f))
5609 {
5610 return qe_invalid;
5611 }
5612 64 }
5613
5614
2/2
✓ Branch 0 taken 4368 times.
✓ Branch 1 taken 1456 times.
5824 for(int32_t j=0; j<3; j++)
5615 {
5616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4368 times.
4368 if(!p_igetw(&temp_misc.shop[i].price[j],f))
5617 {
5618 return qe_invalid;
5619 }
5620 4368 }
5621
5622
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 1233 times.
1456 if(s_version > 3)
5623 {
5624
2/2
✓ Branch 0 taken 3699 times.
✓ Branch 1 taken 1233 times.
4932 for(int32_t j=0; j<3; j++)
5625 {
5626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3699 times.
3699 if(!p_getc(&temp_misc.shop[i].hasitem[j],f))
5627 return qe_invalid;
5628 3699 }
5629 1233 }
5630
5631 /*
5632 if(s_version < 8)
5633 {
5634 for(int32_t j=0; j<3; j++)
5635 {
5636 (&temp_misc.shop[i].str[j])=0; //initialise.
5637 }
5638 }
5639 */
5640 1456 }
5641
5642 //filter all the 0 items to the end (yeah, bubble sort; sue me)
5643
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<maxshops; ++i)
5644 {
5645
2/2
✓ Branch 0 taken 66048 times.
✓ Branch 1 taken 33024 times.
99072 for(int32_t j=0; j<3-1; j++)
5646 {
5647
2/2
✓ Branch 0 taken 66048 times.
✓ Branch 1 taken 96081 times.
162129 for(int32_t k=0; k<2-j; k++)
5648 {
5649 96081 if(temp_misc.shop[i].hasitem[k]==0)
5650 {
5651 96081 swaptmp = temp_misc.shop[i].item[k];
5652 96081 temp_misc.shop[i].item[k] = temp_misc.shop[i].item[k+1];
5653 96081 temp_misc.shop[i].item[k+1] = swaptmp;
5654 96081 swaptmp = temp_misc.shop[i].price[k];
5655 96081 temp_misc.shop[i].price[k] = temp_misc.shop[i].price[k+1];
5656 96081 temp_misc.shop[i].price[k+1] = swaptmp;
5657 96081 swaptmp = temp_misc.shop[i].hasitem[k];
5658 96081 temp_misc.shop[i].hasitem[k] = temp_misc.shop[i].hasitem[k+1];
5659 96081 temp_misc.shop[i].hasitem[k+1] = swaptmp;
5660 96081 }
5661 96081 }
5662 66048 }
5663 33024 }
5664
5665 //infos
5666
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(Header->zelda_version > 0x192)
5667 {
5668
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&infos,f))
5669 {
5670 return qe_invalid;
5671 }
5672 125 }
5673
5674
2/4
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 129 times.
129 if (!(infos >= 0 && infos <= NUM_INFOS))
5675 {
5676 return qe_invalid;
5677 }
5678
5679
5680
2/2
✓ Branch 0 taken 1767 times.
✓ Branch 1 taken 129 times.
1896 for(int32_t i=0; i<infos; i++)
5681 {
5682
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 1667 times.
1767 if(s_version > 6)
5683 {
5684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1667 times.
1667 if(!pfread(temp_misc.info[i].name,sizeof(temp_misc.info[i].name),f))
5685 {
5686 return qe_invalid;
5687 }
5688 1667 }
5689
5690
2/2
✓ Branch 0 taken 5301 times.
✓ Branch 1 taken 1767 times.
7068 for(int32_t j=0; j<3; j++)
5691 {
5692
2/4
✓ Branch 0 taken 5109 times.
✓ Branch 1 taken 192 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5301 if((Header->zelda_version < 0x192)||
5693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5109 times.
5109 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5694 {
5695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&tempbyte,f))
5696 {
5697 return qe_invalid;
5698 }
5699
5700 192 temp_misc.info[i].str[j]=tempbyte;
5701 192 }
5702 else
5703 {
5704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5109 times.
5109 if(!p_igetw(&temp_misc.info[i].str[j],f))
5705 {
5706 return qe_invalid;
5707 }
5708 }
5709 5301 }
5710
5711
2/2
✓ Branch 0 taken 1703 times.
✓ Branch 1 taken 64 times.
1767 if(Header->zelda_version < 0x193)
5712 {
5713
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbyte,f))
5714 {
5715 return qe_invalid;
5716 }
5717 64 }
5718
5719
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1767 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1767 if((Header->zelda_version == 0x192)&&(Header->build>145))
5720 {
5721 if(!p_getc(&padding,f))
5722 {
5723 return qe_invalid;
5724 }
5725 }
5726
5727
2/2
✓ Branch 0 taken 5301 times.
✓ Branch 1 taken 1767 times.
7068 for(int32_t j=0; j<3; j++)
5728 {
5729
1/2
✓ Branch 0 taken 5301 times.
✗ Branch 1 not taken.
5301 if(!p_igetw(&temp_misc.info[i].price[j],f))
5730 {
5731 return qe_invalid;
5732 }
5733 5301 }
5734 1767 }
5735
5736 //filter all the 0 strings to the end (yeah, bubble sort; sue me)
5737
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<maxinfos; ++i)
5738 {
5739
2/2
✓ Branch 0 taken 66048 times.
✓ Branch 1 taken 33024 times.
99072 for(int32_t j=0; j<3-1; j++)
5740 {
5741
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 66048 times.
165120 for(int32_t k=0; k<2-j; k++)
5742 {
5743
2/2
✓ Branch 0 taken 2094 times.
✓ Branch 1 taken 96978 times.
99072 if(temp_misc.info[i].str[k]==0)
5744 {
5745 96978 swaptmp = temp_misc.info[i].str[k];
5746 96978 temp_misc.info[i].str[k] = temp_misc.info[i].str[k+1];
5747 96978 temp_misc.info[i].str[k+1] = swaptmp;
5748 96978 swaptmp = temp_misc.info[i].price[k];
5749 96978 temp_misc.info[i].price[k] = temp_misc.info[i].price[k+1];
5750 96978 temp_misc.info[i].price[k+1] = swaptmp;
5751 96978 }
5752 99072 }
5753 66048 }
5754 33024 }
5755
5756
5757 //warp rings
5758
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 113 times.
129 if(s_version > 5)
5759 113 warprings++;
5760
5761
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(Header->zelda_version > 0x192)
5762 {
5763
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&warprings,f))
5764 {
5765 return qe_invalid;
5766 }
5767
5768
3/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 87 times.
✓ Branch 3 taken 38 times.
125 if (!(warprings >= 0 && warprings <= NUM_WARP_RINGS))
5769 {
5770 // return qe_invalid;
5771 // Note: we can't actually fail here because for some reason, some quest files have more than the max
5772 // number of possible warp rings. Some examples of this are: demosp253.qst, yuurand.qst
5773 // So instead below we disable `keepdata` when reading the bad warp ring data, so no memory is corrupted.
5774 38 }
5775 125 }
5776
5777
2/2
✓ Branch 0 taken 1298 times.
✓ Branch 1 taken 129 times.
1427 for(int32_t i=0; i<warprings; i++)
5778 {
5779 // See above comment on the `warprings` range check.
5780 1298 bool keepdata = i < NUM_WARP_RINGS;
5781
5782
2/2
✓ Branch 0 taken 11458 times.
✓ Branch 1 taken 1298 times.
12756 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5783 {
5784
2/2
✓ Branch 0 taken 1792 times.
✓ Branch 1 taken 9666 times.
11458 if(s_version <= 3)
5785 {
5786
1/2
✓ Branch 0 taken 1792 times.
✗ Branch 1 not taken.
1792 if(!p_getc(&tempbyte,f))
5787 {
5788 return qe_invalid;
5789 }
5790
5791
2/2
✓ Branch 0 taken 672 times.
✓ Branch 1 taken 1120 times.
1792 if (keepdata)
5792 1120 temp_misc.warp[i].dmap[j]=(word)tempbyte;
5793 1792 }
5794 else
5795 {
5796 word tempword;
5797
1/2
✓ Branch 0 taken 9666 times.
✗ Branch 1 not taken.
9666 if(!p_igetw(&tempword,f))
5798 {
5799 return qe_invalid;
5800 }
5801
5802
2/2
✓ Branch 0 taken 513 times.
✓ Branch 1 taken 9153 times.
9666 if (keepdata)
5803 9153 temp_misc.warp[i].dmap[j] = tempword;
5804 }
5805 11458 }
5806
5807
2/2
✓ Branch 0 taken 11458 times.
✓ Branch 1 taken 1298 times.
12756 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5808 {
5809
1/2
✓ Branch 0 taken 11458 times.
✗ Branch 1 not taken.
11458 if(!p_getc(&tempbyte,f))
5810 {
5811 return qe_invalid;
5812 }
5813
2/2
✓ Branch 0 taken 1185 times.
✓ Branch 1 taken 10273 times.
11458 if (keepdata)
5814 10273 temp_misc.warp[i].scr[j] = tempbyte;
5815 11458 }
5816
5817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1298 times.
1298 if(!p_getc(&tempbyte,f))
5818 {
5819 return qe_invalid;
5820 }
5821
2/2
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 1157 times.
1298 if (keepdata)
5822 1157 temp_misc.warp[i].size = tempbyte;
5823
5824
2/2
✓ Branch 0 taken 1266 times.
✓ Branch 1 taken 32 times.
1298 if(Header->zelda_version < 0x193)
5825 {
5826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(!p_getc(&tempbyte,f))
5827 {
5828 return qe_invalid;
5829 }
5830 32 }
5831 1298 }
5832
5833 //palette cycles
5834
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(Header->zelda_version < 0x193) //in 1.93+, palette cycling is saved with the palettes
5835 {
5836
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 4 times.
1028 for(int32_t i=0; i<256; i++)
5837 {
5838
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 1024 times.
4096 for(int32_t j=0; j<3; j++)
5839 {
5840 3072 temp_misc.cycles[i][j].first=0;
5841 3072 temp_misc.cycles[i][j].count=0;
5842 3072 temp_misc.cycles[i][j].speed=0;
5843 3072 }
5844 1024 }
5845
5846
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
5847 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5848 {
5849 4 palcycles=16;
5850 4 }
5851
5852
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 4 times.
68 for(int32_t i=0; i<palcycles; i++)
5853 {
5854
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 64 times.
256 for(int32_t j=0; j<3; j++)
5855 {
5856
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(!p_getc(&temp_misc.cycles[i][j].first,f))
5857 {
5858 return qe_invalid;
5859 }
5860
5861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&temp_misc.cycles[i][j].count,f))
5862 {
5863 return qe_invalid;
5864 }
5865
5866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
5867 {
5868 return qe_invalid;
5869 }
5870 192 }
5871 64 }
5872 4 }
5873
5874 //Wind warps are now just another warp ring.
5875
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version <= 5)
5876 {
5877
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 12 times.
16 if(Header->zelda_version > 0x192)
5878 {
5879
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&windwarps,f))
5880 {
5881 return qe_invalid;
5882 }
5883 12 }
5884
5885
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
16 if (!(windwarps >= 0 && windwarps <= NUM_WARP_RINGS))
5886 {
5887 return qe_invalid;
5888 }
5889
5890
2/2
✓ Branch 0 taken 135 times.
✓ Branch 1 taken 16 times.
151 for(int32_t i=0; i<windwarps; i++)
5891 {
5892
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(s_version <= 3)
5893 {
5894
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(!p_getc(&tempbyte,f))
5895 {
5896 return qe_invalid;
5897 }
5898
5899 135 temp_misc.warp[8].dmap[i]=tempbyte;
5900 135 }
5901 else
5902 {
5903 if(!p_igetw(&temp_misc.warp[8].dmap[i],f))
5904 {
5905 return qe_invalid;
5906 }
5907 }
5908
5909
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(!p_getc(&temp_misc.warp[8].scr[i],f))
5910 {
5911 return qe_invalid;
5912 }
5913
5914 135 temp_misc.warp[8].size = 9;
5915
5916
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(s_version == 5)
5917 {
5918 if(!p_getc(&tempbyte,f))
5919 {
5920 return qe_invalid;
5921 }
5922 }
5923 135 }
5924 16 }
5925
5926
5927 //triforce pieces
5928
2/2
✓ Branch 0 taken 1032 times.
✓ Branch 1 taken 129 times.
1161 for(int32_t i=0; i<triforces; i++)
5929 {
5930
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1032 times.
1032 if(!p_getc(&temp_misc.triforce[i],f))
5931 {
5932 return qe_invalid;
5933 }
5934 1032 }
5935
5936 //misc color data
5937
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<3)
5938 {
5939
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.text,f))
5940 {
5941 return qe_invalid;
5942 }
5943
5944
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.caption,f))
5945 {
5946 return qe_invalid;
5947 }
5948
5949
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.overw_bg,f))
5950 {
5951 return qe_invalid;
5952 }
5953
5954
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5955 {
5956 return qe_invalid;
5957 }
5958
5959
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5960 {
5961 return qe_invalid;
5962 }
5963
5964
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.cave_fg,f))
5965 {
5966 return qe_invalid;
5967 }
5968
5969
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.bs_dk,f))
5970 {
5971 return qe_invalid;
5972 }
5973
5974
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.bs_goal,f))
5975 {
5976 return qe_invalid;
5977 }
5978
5979
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.compass_lt,f))
5980 {
5981 return qe_invalid;
5982 }
5983
5984
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.compass_dk,f))
5985 {
5986 return qe_invalid;
5987 }
5988
5989
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5990 {
5991 return qe_invalid;
5992 }
5993
5994
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.triframe_color,f))
5995 {
5996 return qe_invalid;
5997 }
5998
5999
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.hero_dot,f))
6000 {
6001 return qe_invalid;
6002 }
6003
6004
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.bmap_bg,f))
6005 {
6006 return qe_invalid;
6007 }
6008
6009
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.bmap_fg,f))
6010 {
6011 return qe_invalid;
6012 }
6013
6014
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.triforce_cset,f))
6015 {
6016 return qe_invalid;
6017 }
6018
6019
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.triframe_cset,f))
6020 {
6021 return qe_invalid;
6022 }
6023
6024
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
6025 {
6026 return qe_invalid;
6027 }
6028
6029
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
6030 {
6031 return qe_invalid;
6032 }
6033
6034
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
6035 {
6036 return qe_invalid;
6037 }
6038
6039
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.triforce_tile,f))
6040 {
6041 return qe_invalid;
6042 }
6043
6044
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.triframe_tile,f))
6045 {
6046 return qe_invalid;
6047 }
6048
6049
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.overworld_map_tile,f))
6050 {
6051 return qe_invalid;
6052 }
6053
6054
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.dungeon_map_tile,f))
6055 {
6056 return qe_invalid;
6057 }
6058
6059
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.blueframe_tile,f))
6060 {
6061 return qe_invalid;
6062 }
6063
6064
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.HCpieces_tile,f))
6065 {
6066 return qe_invalid;
6067 }
6068
6069
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
6070 {
6071 return qe_invalid;
6072 }
6073
6074 16 temp_misc.colors.msgtext = 0x01;
6075
6076
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
16 if(Header->zelda_version < 0x193)
6077 {
6078
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 4 times.
32 for(int32_t i=0; i<7; i++)
6079 {
6080
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(!p_getc(&tempbyte,f))
6081 {
6082 return qe_invalid;
6083 }
6084 28 }
6085 4 }
6086
6087
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16 if((Header->zelda_version == 0x192)&&(Header->build>145))
6088 {
6089 for(int32_t i=0; i<256; i++)
6090 {
6091 if(!p_getc(&tempbyte,f))
6092 {
6093 return qe_invalid;
6094 }
6095 }
6096 }
6097
6098
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(s_version>1)
6099 {
6100 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
6101 {
6102 return qe_invalid;
6103 }
6104 }
6105
6106 //save game icons
6107
2/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16 if((Header->zelda_version < 0x192)||
6108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 ((Header->zelda_version == 0x192)&&(Header->build<73)))
6109 {
6110 4 icons=3;
6111 4 }
6112
6113
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 16 times.
76 for(int32_t i=0; i<icons; i++)
6114 {
6115
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_igetw(&temp_misc.icons[i],f))
6116 {
6117 return qe_invalid;
6118 }
6119 60 }
6120 16 }
6121
6122
2/4
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if((Header->zelda_version < 0x192)||
6123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 ((Header->zelda_version == 0x192)&&(Header->build<30)))
6124 {
6125 4 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6126
6127 4 return 0;
6128 }
6129
6130 //pond information
6131
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(Header->zelda_version < 0x193)
6132 {
6133 if((Header->zelda_version == 0x192)&&(Header->build<146))
6134 {
6135 pondsize=25;
6136 }
6137
6138 for(int32_t i=0; i<ponds; i++)
6139 {
6140 for(int32_t j=0; j<pondsize; j++)
6141 {
6142 if(!p_getc(&tempbyte,f))
6143 {
6144 return qe_invalid;
6145
6146 }
6147 }
6148 }
6149 }
6150
6151 //end string
6152
1/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
125 if((Header->zelda_version < 0x192)||
6153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 ((Header->zelda_version == 0x192)&&(Header->build<146)))
6154 {
6155 if(!p_getc(&tempbyte,f))
6156 {
6157 return qe_invalid;
6158 }
6159
6160 temp_misc.endstring=tempbyte;
6161
6162 if(!p_getc(&tempbyte,f))
6163 {
6164 return qe_invalid;
6165 }
6166 }
6167 else
6168 {
6169
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&temp_misc.endstring,f))
6170 {
6171 return qe_invalid;
6172 }
6173 }
6174
6175 //expansion
6176
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(Header->zelda_version < 0x193)
6177 {
6178 if((Header->zelda_version == 0x192)&&(Header->build<73))
6179 {
6180 expansionsize=99*2;
6181 }
6182
6183 for(int32_t i=0; i<expansionsize; i++)
6184 {
6185 if(!p_getc(&tempbyte,f))
6186 {
6187 return qe_invalid;
6188 }
6189 }
6190 }
6191 //shops v8
6192
6193
6194
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 36 times.
125 if(s_version >= 8)
6195 {
6196
2/2
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 36 times.
564 for(int32_t i=0; i<shops; i++)
6197 {
6198
2/2
✓ Branch 0 taken 1584 times.
✓ Branch 1 taken 528 times.
2112 for(int32_t j=0; j<3; j++)
6199 {
6200
1/2
✓ Branch 0 taken 1584 times.
✗ Branch 1 not taken.
1584 if(!p_igetw(&temp_misc.shop[i].str[j],f))
6201 return qe_invalid;
6202 1584 }
6203 528 }
6204 36 }
6205
6206 125 memset(&temp_misc.questmisc, 0, sizeof(int32_t)*32);
6207 125 memset(&temp_misc.questmisc_strings, 0, sizeof(char)*4096);
6208 125 memset(&temp_misc.zscript_last_compiled_version, 0, sizeof(int32_t));
6209
6210 //v9 includes quest misc[32]
6211
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 36 times.
125 if(s_version >= 9)
6212 {
6213
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 36 times.
1188 for ( int32_t q = 0; q < 32; q++ )
6214 {
6215
1/2
✓ Branch 0 taken 1152 times.
✗ Branch 1 not taken.
1152 if(!p_igetl(&temp_misc.questmisc[q],f))
6216 return qe_invalid;
6217 1152 }
6218
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 36 times.
1188 for ( int32_t q = 0; q < 32; q++ )
6219 {
6220
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 1152 times.
148608 for ( int32_t j = 0; j < 128; j++ )
6221
1/2
✓ Branch 0 taken 147456 times.
✗ Branch 1 not taken.
147456 if(!p_getc(&temp_misc.questmisc_strings[q][j],f))
6222 return qe_invalid;
6223 1152 }
6224 36 }
6225
6226
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if(s_version >= 11 )
6227 {
6228
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&temp_misc.zscript_last_compiled_version,f))
6229 return qe_invalid;
6230 36 }
6231
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 else if(s_version < 11 )
6232 {
6233 89 temp_misc.zscript_last_compiled_version = -1;
6234 89 }
6235
6236 125 FFCore.quest_format[vLastCompile] = temp_misc.zscript_last_compiled_version;
6237
6238
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if(s_version >= 12)
6239 {
6240 byte spr;
6241
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 36 times.
9252 for(int32_t q = 0; q < sprMAX; ++q)
6242 {
6243
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_getc(&spr,f))
6244 return qe_invalid;
6245 9216 temp_misc.sprites[q] = spr;
6246 9216 }
6247 36 }
6248 else
6249 {
6250 89 memset(&(temp_misc.sprites), 0, sizeof(temp_misc.sprites));
6251 //temp_misc.sprites[sprFALL] = ;
6252 }
6253
6254
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if(s_version >= 13)
6255 {
6256
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 36 times.
2340 for(size_t q = 0; q < 64; ++q)
6257 {
6258 2304 bottletype* bt = &(temp_misc.bottle_types[q]);
6259
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 if (!pfread(bt->name, 32, f))
6260 return qe_invalid;
6261
2/2
✓ Branch 0 taken 6912 times.
✓ Branch 1 taken 2304 times.
9216 for(size_t j = 0; j < 3; ++j)
6262 {
6263
1/2
✓ Branch 0 taken 6912 times.
✗ Branch 1 not taken.
6912 if (!p_getc(&(bt->counter[j]), f))
6264 return qe_invalid;
6265
1/2
✓ Branch 0 taken 6912 times.
✗ Branch 1 not taken.
6912 if (!p_igetw(&(bt->amount[j]), f))
6266 return qe_invalid;
6267 6912 }
6268
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 if (!p_getc(&(bt->flags), f))
6269 return qe_invalid;
6270
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 if (!p_getc(&(bt->next_type), f))
6271 return qe_invalid;
6272 2304 }
6273
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 36 times.
9252 for(size_t q = 0; q < 256; ++q)
6274 {
6275 9216 bottleshoptype* bst = &(temp_misc.bottle_shop_types[q]);
6276
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if (!pfread(bst->name, 32, f))
6277 return qe_invalid;
6278
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 9216 times.
36864 for(size_t j = 0; j < 3; ++j)
6279 {
6280
1/2
✓ Branch 0 taken 27648 times.
✗ Branch 1 not taken.
27648 if (!p_getc(&(bst->fill[j]), f))
6281 return qe_invalid;
6282
1/2
✓ Branch 0 taken 27648 times.
✗ Branch 1 not taken.
27648 if (!p_igetw(&(bst->comb[j]), f))
6283 return qe_invalid;
6284
1/2
✓ Branch 0 taken 27648 times.
✗ Branch 1 not taken.
27648 if (!p_getc(&(bst->cset[j]), f))
6285 return qe_invalid;
6286
1/2
✓ Branch 0 taken 27648 times.
✗ Branch 1 not taken.
27648 if (!p_igetw(&(bst->price[j]), f))
6287 return qe_invalid;
6288
1/2
✓ Branch 0 taken 27648 times.
✗ Branch 1 not taken.
27648 if (!p_igetw(&(bst->str[j]), f))
6289 return qe_invalid;
6290 27648 }
6291 9216 }
6292 36 }
6293 else
6294 {
6295
2/2
✓ Branch 0 taken 5696 times.
✓ Branch 1 taken 89 times.
5785 for(size_t q = 0; q < 64; ++q)
6296 5696 temp_misc.bottle_types[q].clear();
6297
2/2
✓ Branch 0 taken 22784 times.
✓ Branch 1 taken 89 times.
22873 for(size_t q = 0; q < 256; ++q)
6298 22784 temp_misc.bottle_shop_types[q].clear();
6299 }
6300
6301
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if(s_version >= 14)
6302 {
6303 byte msfx;
6304
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 36 times.
9252 for(int32_t q = 0; q < sfxMAX; ++q)
6305 {
6306
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_getc(&msfx,f))
6307 return qe_invalid;
6308 9216 temp_misc.miscsfx[q] = msfx;
6309 9216 }
6310 36 }
6311 else
6312 {
6313 89 memset(&(temp_misc.miscsfx), 0, sizeof(temp_misc.miscsfx));
6314 89 temp_misc.miscsfx[sfxBUSHGRASS] = WAV_ZN1GRASSCUT;
6315 89 temp_misc.miscsfx[sfxLOWHEART] = WAV_ER;
6316 }
6317
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if(s_version < 15)
6318 {
6319 89 temp_misc.miscsfx[sfxHURTPLAYER] = WAV_OUCH;
6320 89 temp_misc.miscsfx[sfxHAMMERPOUND] = WAV_ZN1HAMMERPOST;
6321 89 temp_misc.miscsfx[sfxSUBSCR_ITEM_ASSIGN] = WAV_PLACE;
6322 89 temp_misc.miscsfx[sfxSUBSCR_CURSOR_MOVE] = WAV_CHIME;
6323 89 temp_misc.miscsfx[sfxREFILL] = WAV_MSG;
6324 89 temp_misc.miscsfx[sfxDRAIN] = WAV_MSG;
6325 89 }
6326
6327 125 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6328
6329 125 return 0;
6330 129 }
6331
6332 extern char *item_string[MAXITEMS];
6333 extern const char *old_item_string[iLast];
6334 extern char *weapon_string[MAXWPNS];
6335 extern const char *old_weapon_string[wLast];
6336
6337 129 int32_t readitems(PACKFILE *f, word version, word build)
6338 {
6339 byte padding;
6340 int32_t dummy;
6341 129 word items_to_read=MAXITEMS;
6342 itemdata tempitem;
6343 129 word s_version=0, s_cversion=0;
6344 word dummy_word;
6345
6346
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(version < 0x186)
6347 {
6348 items_to_read=64;
6349 }
6350
6351
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(version > 0x192)
6352 {
6353 125 items_to_read=0;
6354
6355 //section version info
6356
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_version,f))
6357 {
6358 return qe_invalid;
6359 }
6360
6361 125 FFCore.quest_format[vItems] = s_version;
6362
6363 //al_trace("Items version %d\n", s_version);
6364
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_cversion,f))
6365 {
6366 return qe_invalid;
6367 }
6368
6369 //section size
6370
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&dummy,f))
6371 {
6372 return qe_invalid;
6373 }
6374
6375 //finally... section data
6376
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&items_to_read,f))
6377 {
6378 return qe_invalid;
6379 }
6380
6381
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
125 if (!(items_to_read >= 0 && items_to_read <= MAXITEMS))
6382 {
6383 return qe_invalid;
6384 }
6385 125 }
6386
6387
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version>1)
6388 {
6389
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 113 times.
29041 for(int32_t i=0; i<items_to_read; i++)
6390 {
6391 char tempname[64];
6392
6393
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!pfread(tempname, 64, f))
6394 {
6395 return qe_invalid;
6396 }
6397
6398 28928 item_string[i][0] = '\0';
6399 28928 strncat(item_string[i], tempname, 64 - 1);
6400 28928 }
6401 113 }
6402 else
6403 {
6404
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 16 times.
4112 for(int32_t i=0; i<MAXITEMS; i++)
6405 {
6406 4096 reset_itemname(i);
6407 4096 }
6408 }
6409
6410
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<MAXITEMS; i++)
6411 {
6412 33024 itemdata& id = itemsbuf[i];
6413 33024 memset(&id, 0, sizeof(itemdata));
6414 33024 id.count=-1;
6415 33024 id.playsound=WAV_SCALE;
6416 33024 reset_itembuf(&id,i);
6417 33024 }
6418
6419
2/2
✓ Branch 0 taken 30792 times.
✓ Branch 1 taken 129 times.
30921 for(int32_t i=0; i<items_to_read; i++)
6420 {
6421 30792 memset(&tempitem, 0, sizeof(itemdata));
6422 30792 reset_itembuf(&tempitem,i);
6423
6424
6425
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 21576 times.
30792 if ( s_version > 35 ) //expanded tiles
6426 {
6427
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.tile,f))
6428 {
6429 return qe_invalid;
6430 }
6431 9216 }
6432 else
6433 {
6434
1/2
✓ Branch 0 taken 21576 times.
✗ Branch 1 not taken.
21576 if(!p_igetw(&tempitem.tile,f))
6435 {
6436 return qe_invalid;
6437 }
6438 }
6439
6440
1/2
✓ Branch 0 taken 30792 times.
✗ Branch 1 not taken.
30792 if(!p_getc(&tempitem.misc_flags,f))
6441 {
6442 return qe_invalid;
6443 }
6444
6445
1/2
✓ Branch 0 taken 30792 times.
✗ Branch 1 not taken.
30792 if(!p_getc(&tempitem.csets,f))
6446 {
6447 return qe_invalid;
6448 }
6449
6450
1/2
✓ Branch 0 taken 30792 times.
✗ Branch 1 not taken.
30792 if(!p_getc(&tempitem.frames,f))
6451 {
6452 return qe_invalid;
6453 }
6454
6455
1/2
✓ Branch 0 taken 30792 times.
✗ Branch 1 not taken.
30792 if(!p_getc(&tempitem.speed,f))
6456 {
6457 return qe_invalid;
6458 }
6459
6460
1/2
✓ Branch 0 taken 30792 times.
✗ Branch 1 not taken.
30792 if(!p_getc(&tempitem.delay,f))
6461 {
6462 return qe_invalid;
6463 }
6464
6465
2/2
✓ Branch 0 taken 29768 times.
✓ Branch 1 taken 1024 times.
30792 if(version < 0x193)
6466 {
6467
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&padding,f))
6468 {
6469 return qe_invalid;
6470 }
6471
6472
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1024 if((version < 0x192)||((version == 0x192)&&(build<186)))
6473 {
6474
3/3
✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
1024 switch(i)
6475 {
6476 case iShield:
6477 4 tempitem.ltm=get_qr(qr_BSZELDA)?-12:10;
6478 4 break;
6479
6480 case iMShield:
6481 4 tempitem.ltm=get_qr(qr_BSZELDA)?-6:-10;
6482 4 break;
6483
6484 default:
6485 1016 tempitem.ltm=0;
6486 1016 break;
6487 }
6488
6489 1024 tempitem.count=-1;
6490 1024 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=
6491 1024 tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6492 1024 tempitem.family=0xFF;
6493 1024 tempitem.playsound=WAV_SCALE;
6494 1024 reset_itembuf(&tempitem,i);
6495
6496 1024 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
6497
6498 1024 continue;
6499 }
6500 }
6501
6502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29768 times.
29768 if(!p_igetl(&tempitem.ltm,f))
6503 {
6504 return qe_invalid;
6505 }
6506
6507
1/2
✓ Branch 0 taken 29768 times.
✗ Branch 1 not taken.
29768 if(version < 0x193)
6508 {
6509 for(int32_t q=0; q<12; q++)
6510 {
6511 if(!p_getc(&padding,f))
6512 {
6513 return qe_invalid;
6514 }
6515 }
6516 }
6517
6518
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 840 times.
29768 if(s_version>1)
6519 {
6520
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 19712 times.
28928 if ( s_version >= 31 )
6521 {
6522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.family,f))
6523 {
6524 return qe_invalid;
6525 }
6526 9216 }
6527 else
6528 {
6529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19712 times.
19712 if(!p_getc(&tempitem.family,f))
6530 {
6531 return qe_invalid;
6532 }
6533 }
6534
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(s_version < 16)
6535 if(tempitem.family == 0xFF)
6536 tempitem.family = itype_misc;
6537
6538
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.fam_type,f))
6539 {
6540 return qe_invalid;
6541 }
6542
6543
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(s_version>5)
6544 {
6545
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 19712 times.
28928 if(s_version>=31)
6546 {
6547
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.power,f))
6548 {
6549 return qe_invalid;
6550 }
6551 9216 }
6552 else
6553 {
6554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19712 times.
19712 if(!p_getc(&tempitem.power,f))
6555 {
6556 return qe_invalid;
6557 }
6558 }
6559
6560 //converted flags from 16b to 32b -Z
6561
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version < 41 )
6562 {
6563
1/2
✓ Branch 0 taken 19712 times.
✗ Branch 1 not taken.
19712 if(!p_igetw(&tempitem.flags,f))
6564 {
6565 return qe_invalid;
6566 }
6567 19712 }
6568 else
6569 {
6570
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.flags,f))
6571 {
6572 return qe_invalid;
6573 }
6574 }
6575 28928 }
6576 else
6577 {
6578 //tempitem.power = tempitem.fam_type;
6579 char tempchar;
6580
6581 if(!p_getc(&tempchar,f))
6582 {
6583 return qe_invalid;
6584 }
6585
6586 tempitem.flags |= (tempchar ? ITEM_GAMEDATA : 0);
6587 }
6588
6589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_igetw(&tempitem.script,f))
6590 {
6591 return qe_invalid;
6592 }
6593
6594
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(s_version<=3)
6595 {
6596 if(tempitem.script > NUMSCRIPTITEM)
6597 {
6598 tempitem.script = 0;
6599 }
6600 }
6601
6602
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.count,f))
6603 {
6604 return qe_invalid;
6605 }
6606
6607
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_igetw(&tempitem.amount,f))
6608 {
6609 return qe_invalid;
6610 }
6611
6612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_igetw(&tempitem.collect_script,f))
6613 {
6614 return qe_invalid;
6615 }
6616
6617
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(s_version<=3)
6618 {
6619 if(tempitem.collect_script > NUMSCRIPTITEM)
6620 {
6621 tempitem.collect_script = 0;
6622 }
6623 }
6624
6625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_igetw(&tempitem.setmax,f))
6626 {
6627 return qe_invalid;
6628 }
6629
6630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_igetw(&tempitem.max,f))
6631 {
6632 return qe_invalid;
6633 }
6634
6635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_getc(&tempitem.playsound,f))
6636 {
6637 return qe_invalid;
6638 }
6639
6640
2/2
✓ Branch 0 taken 231424 times.
✓ Branch 1 taken 28928 times.
260352 for(int32_t j=0; j<8; j++)
6641 {
6642
1/2
✓ Branch 0 taken 231424 times.
✗ Branch 1 not taken.
231424 if(!p_igetl(&tempitem.initiald[j],f))
6643 {
6644 return qe_invalid;
6645 }
6646 231424 }
6647
6648
2/2
✓ Branch 0 taken 57856 times.
✓ Branch 1 taken 28928 times.
86784 for(int32_t j=0; j<2; j++)
6649 {
6650
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&tempitem.initiala[j],f))
6651 {
6652 return qe_invalid;
6653 }
6654 57856 }
6655
6656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(s_version>4)
6657 {
6658
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(s_version>5)
6659 {
6660
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.wpn,f))
6661 {
6662 return qe_invalid;
6663 }
6664
6665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_getc(&tempitem.wpn2,f))
6666 {
6667 return qe_invalid;
6668 }
6669
6670
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.wpn3,f))
6671 {
6672 return qe_invalid;
6673 }
6674
6675
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.wpn4,f))
6676 {
6677 return qe_invalid;
6678 }
6679
6680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(s_version>=15)
6681 {
6682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_getc(&tempitem.wpn5,f))
6683 {
6684 return qe_invalid;
6685 }
6686
6687
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.wpn6,f))
6688 {
6689 return qe_invalid;
6690 }
6691
6692
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.wpn7,f))
6693 {
6694 return qe_invalid;
6695 }
6696
6697
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.wpn8,f))
6698 {
6699 return qe_invalid;
6700 }
6701
6702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_getc(&tempitem.wpn9,f))
6703 {
6704 return qe_invalid;
6705 }
6706
6707
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.wpn10,f))
6708 {
6709 return qe_invalid;
6710 }
6711 28928 }
6712
6713
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.pickup_hearts,f))
6714 {
6715 return qe_invalid;
6716 }
6717
6718
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(s_version<15)
6719 {
6720 if(!p_igetw(&dummy_word,f))
6721 {
6722 return qe_invalid;
6723 }
6724
6725 tempitem.misc1=dummy_word;
6726
6727 if(!p_igetw(&dummy_word,f))
6728 {
6729 return qe_invalid;
6730 }
6731
6732 tempitem.misc2=dummy_word;
6733 }
6734 else
6735 {
6736
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_igetl(&tempitem.misc1,f))
6737 {
6738 return qe_invalid;
6739 }
6740
6741
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_igetl(&tempitem.misc2,f))
6742 {
6743 return qe_invalid;
6744 }
6745
6746 // Version 24: shICE -> shSCRIPT; previously, all shields could block script weapons
6747
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(s_version<24)
6748 {
6749 if(tempitem.family==itype_shield)
6750 {
6751 tempitem.misc1|=shSCRIPT;
6752 }
6753 }
6754 }
6755
6756
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if(s_version < 53)
6757 {
6758 byte tempbyte;
6759
1/2
✓ Branch 0 taken 19712 times.
✗ Branch 1 not taken.
19712 if(!p_getc(&tempbyte,f))
6760 {
6761 return qe_invalid;
6762 }
6763 19712 tempitem.cost_amount[0] = tempbyte;
6764 19712 }
6765 else
6766 {
6767
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 9216 times.
27648 for(auto q = 0; q < 2; ++q)
6768 {
6769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18432 times.
18432 if(!p_igetw(&tempitem.cost_amount[q],f))
6770 {
6771 return qe_invalid;
6772 }
6773 18432 }
6774 }
6775 28928 }
6776 else
6777 {
6778 char tempchar;
6779
6780 if(!p_getc(&tempchar,f))
6781 {
6782 return qe_invalid;
6783 }
6784
6785 tempitem.flags |= (tempchar ? ITEM_EDIBLE : 0);
6786 }
6787
6788 // June 2007: more misc. attributes
6789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(s_version>=12)
6790 {
6791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(s_version<15)
6792 {
6793 if(!p_igetw(&dummy_word,f))
6794 {
6795 return qe_invalid;
6796 }
6797
6798 tempitem.misc3=dummy_word;
6799
6800 if(!p_igetw(&dummy_word,f))
6801 {
6802 return qe_invalid;
6803 }
6804
6805 tempitem.misc4=dummy_word;
6806 }
6807 else
6808 {
6809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_igetl(&tempitem.misc3,f))
6810 {
6811 return qe_invalid;
6812 }
6813
6814
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_igetl(&tempitem.misc4,f))
6815 {
6816 return qe_invalid;
6817 }
6818
6819
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_igetl(&tempitem.misc5,f))
6820 {
6821 return qe_invalid;
6822 }
6823
6824
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_igetl(&tempitem.misc6,f))
6825 {
6826 return qe_invalid;
6827 }
6828
6829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_igetl(&tempitem.misc7,f))
6830 {
6831 return qe_invalid;
6832 }
6833
6834
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_igetl(&tempitem.misc8,f))
6835 {
6836 return qe_invalid;
6837 }
6838
6839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_igetl(&tempitem.misc9,f))
6840 {
6841 return qe_invalid;
6842 }
6843
6844
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_igetl(&tempitem.misc10,f))
6845 {
6846 return qe_invalid;
6847 }
6848 }
6849
6850
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.usesound,f))
6851 {
6852 return qe_invalid;
6853 }
6854
6855
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 19712 times.
28928 if(s_version >= 49)
6856 {
6857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_getc(&tempitem.usesound2,f))
6858 {
6859 return qe_invalid;
6860 }
6861 9216 }
6862 19712 else tempitem.usesound2 = 0;
6863
6864
3/4
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
✓ Branch 2 taken 19712 times.
✗ Branch 3 not taken.
28928 if(s_version < 50 && tempitem.family == itype_mirror)
6865 {
6866 //Split continue/dmap warp effect/sfx, port for old
6867 tempitem.misc2 = tempitem.misc1;
6868 tempitem.usesound2 = tempitem.usesound;
6869 }
6870 28928 }
6871 28928 }
6872
6873
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version >= 26 ) //! New itemdata vars for weapon editor. -Z
6874 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_getc(&tempitem.useweapon,f))
6876 {
6877 return qe_invalid;
6878 }
6879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_getc(&tempitem.usedefence,f))
6880 {
6881 return qe_invalid;
6882 }
6883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.weaprange,f))
6884 {
6885 return qe_invalid;
6886 }
6887
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.weapduration,f))
6888 {
6889 return qe_invalid;
6890 }
6891
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 9216 times.
101376 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ )
6892 {
6893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92160 times.
92160 if(!p_igetl(&tempitem.weap_pattern[q],f))
6894 {
6895 return qe_invalid;
6896 }
6897 92160 }
6898 9216 }
6899
6900
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version >= 27 ) //! New itemdata vars for weapon editor. -Z
6901 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6902
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.duplicates,f))
6903 {
6904 return qe_invalid;
6905 }
6906
2/2
✓ Branch 0 taken 73728 times.
✓ Branch 1 taken 9216 times.
82944 for ( int32_t q = 0; q < INITIAL_D; q++ )
6907 {
6908
1/2
✓ Branch 0 taken 73728 times.
✗ Branch 1 not taken.
73728 if(!p_igetl(&tempitem.weap_initiald[q],f))
6909 {
6910 return qe_invalid;
6911 }
6912 73728 }
6913
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 9216 times.
27648 for ( int32_t q = 0; q < INITIAL_A; q++ )
6914 {
6915
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_getc(&tempitem.weap_initiala[q],f))
6916 {
6917 return qe_invalid;
6918 }
6919 18432 }
6920
6921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_getc(&tempitem.drawlayer,f))
6922 {
6923 return qe_invalid;
6924 }
6925
6926
6927
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.hxofs,f))
6928 {
6929 return qe_invalid;
6930 }
6931
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.hyofs,f))
6932 {
6933 return qe_invalid;
6934 }
6935
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.hxsz,f))
6936 {
6937 return qe_invalid;
6938 }
6939
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.hysz,f))
6940 {
6941 return qe_invalid;
6942 }
6943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.hzsz,f))
6944 {
6945 return qe_invalid;
6946 }
6947
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.xofs,f))
6948 {
6949 return qe_invalid;
6950 }
6951
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.yofs,f))
6952 {
6953 return qe_invalid;
6954 }
6955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.weap_hxofs,f))
6956 {
6957 return qe_invalid;
6958 }
6959
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.weap_hyofs,f))
6960 {
6961 return qe_invalid;
6962 }
6963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.weap_hxsz,f))
6964 {
6965 return qe_invalid;
6966 }
6967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.weap_hysz,f))
6968 {
6969 return qe_invalid;
6970 }
6971
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.weap_hzsz,f))
6972 {
6973 return qe_invalid;
6974 }
6975
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.weap_xofs,f))
6976 {
6977 return qe_invalid;
6978 }
6979
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.weap_yofs,f))
6980 {
6981 return qe_invalid;
6982 }
6983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetw(&tempitem.weaponscript,f))
6984 {
6985 return qe_invalid;
6986 }
6987
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.wpnsprite,f))
6988 {
6989 return qe_invalid;
6990 }
6991 9216 auto num_cost_tmr = (s_version > 52 ? 2 : 1);
6992
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 9216 times.
27648 for(auto q = 0; q < num_cost_tmr; ++q)
6993 {
6994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18432 times.
18432 if(!p_igetl(&tempitem.magiccosttimer[q],f))
6995 {
6996 return qe_invalid;
6997 }
6998 18432 }
6999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 for(auto q = num_cost_tmr; q < 2; ++q)
7000 tempitem.magiccosttimer[q] = 0;
7001 9216 }
7002
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version >= 28 ) //! New itemdata vars for weapon editor. -Z
7003 {
7004 //Item Size FLags, TileWidth, TileHeight
7005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.overrideFLAGS,f))
7006 {
7007 return qe_invalid;
7008 }
7009
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.tilew,f))
7010 {
7011 return qe_invalid;
7012 }
7013
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.tileh,f))
7014 {
7015 return qe_invalid;
7016 }
7017 9216 }
7018
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version >= 29 ) //! More new vars.
7019 {
7020 //Item Size FLags, TileWidth, TileHeight
7021
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.weapoverrideFLAGS,f))
7022 {
7023 return qe_invalid;
7024 }
7025
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.weap_tilew,f))
7026 {
7027 return qe_invalid;
7028 }
7029
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.weap_tileh,f))
7030 {
7031 return qe_invalid;
7032 }
7033 9216 }
7034
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version >= 30 ) //! More new vars.
7035 {
7036 //Pickup Type
7037
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.pickup,f))
7038 {
7039 return qe_invalid;
7040 }
7041 9216 }
7042
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version >= 32 ) //! More new vars.
7043 {
7044 //Pickup Type
7045
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetw(&tempitem.pstring,f))
7046 {
7047 return qe_invalid;
7048 }
7049 9216 }
7050
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version >= 33 ) //! More new vars.
7051 {
7052 //Pickup Type
7053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetw(&tempitem.pickup_string_flags,f))
7054 {
7055 return qe_invalid;
7056 }
7057 9216 }
7058
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version >= 34 ) //! cost counter
7059 {
7060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(s_version < 53)
7061 {
7062 if(!p_getc(&tempitem.cost_counter[0],f))
7063 {
7064 return qe_invalid;
7065 }
7066 }
7067 else
7068 {
7069
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 9216 times.
27648 for(auto q = 0; q < 2; ++q)
7070 {
7071
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_getc(&tempitem.cost_counter[q],f))
7072 {
7073 return qe_invalid;
7074 }
7075 18432 }
7076 }
7077 9216 }
7078
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version >= 44 ) //! sprite scripts
7079 {
7080
2/2
✓ Branch 0 taken 73728 times.
✓ Branch 1 taken 9216 times.
82944 for ( int32_t q = 0; q < 8; q++ )
7081 {
7082
2/2
✓ Branch 0 taken 4792320 times.
✓ Branch 1 taken 73728 times.
4866048 for ( int32_t w = 0; w < 65; w++ )
7083 {
7084
1/2
✓ Branch 0 taken 4792320 times.
✗ Branch 1 not taken.
4792320 if(!p_getc(&(tempitem.initD_label[q][w]),f))
7085 {
7086 return qe_invalid;
7087 }
7088 4792320 }
7089
2/2
✓ Branch 0 taken 4792320 times.
✓ Branch 1 taken 73728 times.
4866048 for ( int32_t w = 0; w < 65; w++ )
7090 {
7091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4792320 times.
4792320 if(!p_getc(&(tempitem.weapon_initD_label[q][w]),f))
7092 {
7093 return qe_invalid;
7094 }
7095 4792320 }
7096
2/2
✓ Branch 0 taken 4792320 times.
✓ Branch 1 taken 73728 times.
4866048 for ( int32_t w = 0; w < 65; w++ )
7097 {
7098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4792320 times.
4792320 if(!p_getc(&(tempitem.sprite_initD_label[q][w]),f))
7099 {
7100 return qe_invalid;
7101 }
7102 4792320 }
7103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73728 times.
73728 if(!p_igetl(&(tempitem.sprite_initiald[q]),f))
7104 {
7105 return qe_invalid;
7106 }
7107
7108 73728 }
7109
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 9216 times.
27648 for ( int32_t q = 0; q < 2; q++ )
7110 {
7111
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18432 times.
18432 if(!p_getc(&(tempitem.sprite_initiala[q]),f))
7112 {
7113 return qe_invalid;
7114 }
7115 18432 }
7116 //Pickup Type
7117
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetw(&tempitem.sprite_script,f))
7118 {
7119 return qe_invalid;
7120 }
7121 9216 }
7122
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version >= 48 ) //! pickup flags
7123 {
7124
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_getc(&(tempitem.pickupflag),f))
7125 {
7126 return qe_invalid;
7127 }
7128 9216 }
7129
2/2
✓ Branch 0 taken 21248 times.
✓ Branch 1 taken 7680 times.
28928 if ( s_version >= 57 )
7130 {
7131 7680 std::string str;
7132
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
✓ Branch 2 taken 7680 times.
✗ Branch 3 not taken.
7680 if(!p_getcstr(&str,f))
7133 return qe_invalid;
7134 7680 strncpy(tempitem.display_name,str.c_str(),255);
7135
1/3
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
7680 }
7136 28928 }
7137 else
7138 {
7139 840 tempitem.count=-1;
7140 840 tempitem.family=itype_misc;
7141 840 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
7142 840 tempitem.playsound=WAV_SCALE;
7143 840 reset_itembuf(&tempitem,i);
7144 }
7145
7146 29768 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
7147 29768 }
7148
7149 //////////////////////////////////////////////////////
7150 // Now do any updates because of new item additions
7151 // (These can't be done above because items_to_read
7152 // might be too low.)
7153 //////////////////////////////////////////////////////
7154
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<MAXITEMS; i++)
7155 {
7156 33024 memcpy(&tempitem, &itemsbuf[i], sizeof(itemdata));
7157
7158 //Account for older quests that didn't have an actual item for the used letter
7159
4/4
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 28928 times.
✓ Branch 2 taken 4080 times.
✓ Branch 3 taken 16 times.
33024 if(s_version < 2 && i==iLetterUsed)
7160 {
7161 16 reset_itembuf(&tempitem, iLetterUsed);
7162 16 strcpy(item_string[i],old_item_string[i]);
7163 16 tempitem.tile = itemsbuf[iLetter].tile;
7164 16 tempitem.csets = itemsbuf[iLetter].csets;
7165 16 tempitem.misc_flags = itemsbuf[iLetter].misc_flags;
7166 16 tempitem.frames = itemsbuf[iLetter].frames;
7167 16 tempitem.speed = itemsbuf[iLetter].speed;
7168 16 tempitem.ltm = itemsbuf[iLetter].ltm;
7169 16 }
7170
7171
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 3)
7172 {
7173
3/3
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 3728 times.
✓ Branch 2 taken 16 times.
4096 switch(i)
7174 {
7175 case iRocsFeather:
7176 case iHoverBoots:
7177 case iSpinScroll:
7178 case iL2SpinScroll:
7179 case iCrossScroll:
7180 case iQuakeScroll:
7181 case iL2QuakeScroll:
7182 case iWhispRing:
7183 case iL2WhispRing:
7184 case iChargeRing:
7185 case iL2ChargeRing:
7186 case iPerilScroll:
7187 case iWalletL3:
7188 case iQuiverL4:
7189 case iBombBagL4:
7190 case iBracelet:
7191 case iL2Bracelet:
7192 case iOldGlove:
7193 case iL2Ladder:
7194 case iWealthMedal:
7195 case iL2WealthMedal:
7196 case iL3WealthMedal:
7197 352 reset_itembuf(&tempitem, i);
7198 352 strcpy(item_string[i],old_item_string[i]);
7199 352 break;
7200
7201 case iSShield:
7202 16 reset_itembuf(&tempitem, i);
7203 16 strcpy(item_string[i],old_item_string[i]);
7204 16 strcpy(item_string[iShield],old_item_string[iShield]);
7205 16 strcpy(item_string[iMShield],old_item_string[iMShield]);
7206 16 break;
7207 }
7208 4096 }
7209
7210
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 5)
7211 {
7212
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 3984 times.
4096 switch(i)
7213 {
7214 case iHeartRing:
7215 case iL2HeartRing:
7216 case iL3HeartRing:
7217 case iMagicRing:
7218 case iL2MagicRing:
7219 case iL3MagicRing:
7220 case iL4MagicRing:
7221 112 reset_itembuf(&tempitem, i);
7222 112 strcpy(item_string[i],old_item_string[i]);
7223 112 break;
7224 }
7225 4096 }
7226
7227
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 6) // April 2007: Advanced item editing capabilities.
7228 {
7229
4/4
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4064 times.
4096 if(i!=iBPotion && i!=iRPotion)
7230 4064 tempitem.flags |= get_bit(deprecated_rules,32) ? ITEM_KEEPOLD : 0;
7231
7232
43/43
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 16 times.
✓ Branch 7 taken 16 times.
✓ Branch 8 taken 16 times.
✓ Branch 9 taken 16 times.
✓ Branch 10 taken 16 times.
✓ Branch 11 taken 16 times.
✓ Branch 12 taken 16 times.
✓ Branch 13 taken 16 times.
✓ Branch 14 taken 16 times.
✓ Branch 15 taken 16 times.
✓ Branch 16 taken 16 times.
✓ Branch 17 taken 16 times.
✓ Branch 18 taken 16 times.
✓ Branch 19 taken 16 times.
✓ Branch 20 taken 16 times.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 64 times.
✓ Branch 23 taken 3376 times.
✓ Branch 24 taken 16 times.
✓ Branch 25 taken 16 times.
✓ Branch 26 taken 16 times.
✓ Branch 27 taken 16 times.
✓ Branch 28 taken 16 times.
✓ Branch 29 taken 16 times.
✓ Branch 30 taken 16 times.
✓ Branch 31 taken 16 times.
✓ Branch 32 taken 16 times.
✓ Branch 33 taken 16 times.
✓ Branch 34 taken 16 times.
✓ Branch 35 taken 16 times.
✓ Branch 36 taken 16 times.
✓ Branch 37 taken 16 times.
✓ Branch 38 taken 16 times.
✓ Branch 39 taken 16 times.
✓ Branch 40 taken 16 times.
✓ Branch 41 taken 16 times.
✓ Branch 42 taken 16 times.
4096 switch(i)
7233 {
7234 case iTriforce:
7235 16 tempitem.fam_type=1;
7236 16 break;
7237
7238 case iBigTri:
7239 16 tempitem.fam_type=0;
7240 16 break;
7241
7242 case iBombs:
7243 16 tempitem.fam_type=i_bomb;
7244 16 tempitem.power=4;
7245 16 tempitem.wpn=wBOMB;
7246 16 tempitem.wpn2=wBOOM;
7247 16 tempitem.misc1 = 50;
7248
7249
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 200;
7250
7251 16 break;
7252
7253 case iSBomb:
7254 16 tempitem.fam_type=i_sbomb;
7255 16 tempitem.power=16;
7256 16 tempitem.wpn=wSBOMB;
7257 16 tempitem.wpn2=wSBOOM;
7258 16 tempitem.misc1 = 50;
7259
7260
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 400;
7261
7262 16 break;
7263
7264 case iBook:
7265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(get_bit(deprecated_rules, qr_FIREMAGICSPRITE_DEP))
7266 tempitem.wpn = wFIREMAGIC;
7267
7268 16 break;
7269
7270 case iSArrow:
7271 16 tempitem.wpn2 = get_bit(deprecated_rules,27) ? wSSPARKLE : 0; //qr_SASPARKLES
7272 16 tempitem.power=4;
7273 16 tempitem.flags|=ITEM_GAMEDATA;
7274 16 tempitem.wpn=wSARROW;
7275 16 break;
7276
7277 case iGArrow:
7278 16 tempitem.wpn2 = get_bit(deprecated_rules,28) ? wGSPARKLE : 0; //qr_GASPARKLES
7279 16 tempitem.power=8;
7280 16 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7281 16 tempitem.wpn=wGARROW;
7282 16 break;
7283
7284 case iBrang:
7285 16 tempitem.power=0;
7286 16 tempitem.wpn=wBRANG;
7287 16 tempitem.misc1=36;
7288 16 break;
7289
7290 case iMBrang:
7291 16 tempitem.wpn2 = get_bit(deprecated_rules,29) ? wMSPARKLE : 0; //qr_MBSPARKLES
7292 16 tempitem.power=0;
7293 16 tempitem.wpn=wMBRANG;
7294 16 break;
7295
7296 case iFBrang:
7297 16 tempitem.wpn3 = get_bit(deprecated_rules,30) ? wFSPARKLE : 0; //qr_FBSPARKLES
7298 16 tempitem.power=2;
7299 16 tempitem.wpn=wFBRANG;
7300 16 break;
7301
7302 case iBoots:
7303 16 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICBOOTS_DEP) ? 1 : 0;
7304 16 tempitem.power=7;
7305 16 break;
7306
7307 case iWand:
7308 16 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICWAND_DEP) ? 8 : 0;
7309 16 tempitem.power=2;
7310 16 tempitem.wpn=wWAND;
7311 16 tempitem.wpn3=wMAGIC;
7312 16 break;
7313
7314 case iBCandle:
7315 16 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7316 16 tempitem.power=1;
7317 16 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7318 16 tempitem.wpn3=wFIRE;
7319 16 break;
7320
7321 case iRCandle:
7322 16 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7323 16 tempitem.power=1;
7324 16 tempitem.wpn3=wFIRE;
7325 16 break;
7326
7327 case iSword:
7328 16 tempitem.power=1;
7329 16 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7330 16 tempitem.wpn=tempitem.wpn3=wSWORD;
7331 16 tempitem.wpn2=wSWORDSLASH;
7332 16 break;
7333
7334 case iWSword:
7335 16 tempitem.power=2;
7336 16 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7337 16 tempitem.wpn=tempitem.wpn3=wWSWORD;
7338 16 tempitem.wpn2=wWSWORDSLASH;
7339 16 break;
7340
7341 case iMSword:
7342 16 tempitem.power=4;
7343 16 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7344 16 tempitem.wpn=tempitem.wpn3=wMSWORD;
7345 16 tempitem.wpn2=wMSWORDSLASH;
7346 16 break;
7347
7348 case iXSword:
7349 16 tempitem.power=8;
7350 16 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7351 16 tempitem.wpn=tempitem.wpn3=wXSWORD;
7352 16 tempitem.wpn2=wXSWORDSLASH;
7353 16 break;
7354
7355 case iDivineProtection:
7356 16 tempitem.flags |= get_bit(deprecated_rules,qr_FLICKERINGDIVINEPROTECTIONROCKET_DEP) ? ITEM_FLAG1 : 0;
7357 16 tempitem.flags |= get_bit(deprecated_rules,qr_TRANSLUCENTDIVINEPROTECTIONROCKET_DEP) ? ITEM_FLAG2 : 0;
7358 16 tempitem.wpn=wDIVINEPROTECTION1A;
7359 16 tempitem.wpn2=wDIVINEPROTECTION1B;
7360 16 tempitem.wpn3=wDIVINEPROTECTIONS1A;
7361 16 tempitem.wpn4=wDIVINEPROTECTIONS1B;
7362 16 tempitem.wpn6=wDIVINEPROTECTION2A;
7363 16 tempitem.wpn7=wDIVINEPROTECTION2B;
7364 16 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7365 16 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7366 16 tempitem.wpn5 = iwDivineProtectionShieldFront;
7367 16 tempitem.wpn10 = iwDivineProtectionShieldBack;
7368 16 tempitem.misc1=512;
7369 16 tempitem.cost_amount[0]=64;
7370 16 break;
7371
7372 case iLens:
7373 16 tempitem.misc1=60;
7374 16 tempitem.flags |= get_qr(qr_ENABLEMAGIC) ? 0 : ITEM_RUPEE_MAGIC;
7375 16 tempitem.cost_amount[0] = get_qr(qr_ENABLEMAGIC) ? 2 : 1;
7376 16 break;
7377
7378 case iArrow:
7379 16 tempitem.power=2;
7380 16 tempitem.wpn=wARROW;
7381 16 break;
7382
7383 case iHoverBoots:
7384 16 tempitem.misc1=45;
7385 16 tempitem.wpn=iwHover;
7386 16 break;
7387
7388 case iDivineFire:
7389 16 tempitem.power=8;
7390 16 tempitem.wpn=wDIVINEFIRE1A;
7391 16 tempitem.wpn2=wDIVINEFIRE1B;
7392 16 tempitem.wpn3=wDIVINEFIRES1A;
7393 16 tempitem.wpn4=wDIVINEFIRES1B;
7394 16 tempitem.misc1 = 32;
7395 16 tempitem.misc2 = 200;
7396 16 tempitem.cost_amount[0]=32;
7397 16 break;
7398
7399 case iDivineEscape:
7400 16 tempitem.cost_amount[0]=32;
7401 16 break;
7402
7403 case iHookshot:
7404 16 tempitem.power=0;
7405 16 tempitem.flags&=~ITEM_FLAG1;
7406 16 tempitem.wpn=wHSHEAD;
7407 16 tempitem.wpn2=wHSCHAIN_H;
7408 16 tempitem.wpn4=wHSHANDLE;
7409 16 tempitem.wpn3=wHSCHAIN_V;
7410 16 tempitem.misc1=50;
7411 16 tempitem.misc2=100;
7412 16 break;
7413
7414 case iLongshot:
7415 16 tempitem.power=0;
7416 16 tempitem.flags&=~ITEM_FLAG1;
7417 16 tempitem.wpn=wLSHEAD;
7418 16 tempitem.wpn2=wLSCHAIN_H;
7419 16 tempitem.wpn4=wLSHANDLE;
7420 16 tempitem.wpn3=wLSCHAIN_V;
7421 16 tempitem.misc1=99;
7422 16 tempitem.misc2=100;
7423 16 break;
7424
7425 case iHammer:
7426 16 tempitem.power=4;
7427 16 tempitem.wpn=wHAMMER;
7428 16 tempitem.wpn2=iwHammerSmack;
7429 16 break;
7430
7431 case iCByrna:
7432 16 tempitem.power=1;
7433 16 tempitem.wpn=wCBYRNA;
7434 16 tempitem.wpn2=wCBYRNASLASH;
7435 16 tempitem.wpn3=wCBYRNAORB;
7436 16 tempitem.misc1=4;
7437 16 tempitem.misc2=16;
7438 16 tempitem.misc3=1;
7439 16 tempitem.cost_amount[0]=1;
7440 16 break;
7441
7442 case iWhistle:
7443 16 tempitem.wpn=wWIND;
7444 16 tempitem.misc1=3;
7445 16 tempitem.flags|=ITEM_FLAG1;
7446 16 break;
7447
7448 case iBRing:
7449 16 tempitem.power=2;
7450 16 tempitem.misc1=spBLUE;
7451 16 break;
7452
7453 case iRRing:
7454 16 tempitem.power=4;
7455 16 tempitem.misc1=spRED;
7456 16 break;
7457
7458 case iGRing:
7459 16 tempitem.power=8;
7460 16 tempitem.misc1=spGOLD;
7461 16 break;
7462
7463 case iSpinScroll:
7464 16 tempitem.power = 2;
7465 16 tempitem.misc1 = 1;
7466 16 break;
7467
7468 case iL2SpinScroll:
7469 16 tempitem.family=itype_spinscroll2;
7470 16 tempitem.fam_type=1;
7471 16 tempitem.cost_amount[0]=8;
7472 16 tempitem.power=2;
7473 16 tempitem.misc1 = 20;
7474 16 break;
7475
7476 case iQuakeScroll:
7477 16 tempitem.misc1=0x10;
7478 16 tempitem.misc2=64;
7479 16 break;
7480
7481 case iL2QuakeScroll:
7482 16 tempitem.family=itype_quakescroll2;
7483 16 tempitem.fam_type=1;
7484 16 tempitem.power = 2;
7485 16 tempitem.misc1=0x20;
7486 16 tempitem.misc2=192;
7487 16 tempitem.cost_amount[0]=8;
7488 16 break;
7489
7490 case iChargeRing:
7491 16 tempitem.misc1=64;
7492 16 tempitem.misc2=128;
7493 16 break;
7494
7495 case iL2ChargeRing:
7496 16 tempitem.misc1=32;
7497 16 tempitem.misc2=64;
7498 16 break;
7499
7500 case iOldGlove:
7501 16 tempitem.flags |= ITEM_FLAG1;
7502
7503 //fallthrough
7504 case iBombBagL4:
7505 case iWalletL3:
7506 case iQuiverL4:
7507 case iBracelet:
7508 80 tempitem.power = 1;
7509 80 break;
7510
7511 case iL2Bracelet:
7512 16 tempitem.power = 2;
7513 16 break;
7514
7515 case iMKey:
7516 16 tempitem.power=0xFF;
7517 16 tempitem.flags |= ITEM_FLAG1;
7518 16 break;
7519 }
7520 4096 }
7521
7522
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 7)
7523 {
7524
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 4032 times.
4096 switch(i)
7525 {
7526 case iStoneAgony:
7527 case iStompBoots:
7528 case iPerilRing:
7529 case iWhimsicalRing:
7530 {
7531 64 reset_itembuf(&tempitem, i);
7532 64 strcpy(item_string[i],old_item_string[i]);
7533 64 break;
7534 }
7535 }
7536 4096 }
7537
7538
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 8) // May 2007: Some corrections.
7539 {
7540
7/7
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 48 times.
✓ Branch 3 taken 3968 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 16 times.
4096 switch(i)
7541 {
7542 case iMShield:
7543 16 tempitem.misc1|=shFLAME;
7544 16 tempitem.misc2|=shFIREBALL|shMAGIC;
7545
7546
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(get_qr(qr_SWORDMIRROR))
7547 {
7548 tempitem.misc2 |= shSWORD;
7549 }
7550
7551 // fallthrough
7552 case iShield:
7553 32 tempitem.misc1|=shFIREBALL|shSWORD|shMAGIC;
7554
7555 // fallthrough
7556 case iSShield:
7557 48 tempitem.misc1|=shROCK|shARROW|shBRANG|shSCRIPT;
7558
7559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(get_bit(deprecated_rules,102)) //qr_REFLECTROCKS
7560 {
7561 tempitem.misc2 |= shROCK;
7562 }
7563
7564 48 break;
7565
7566 case iWhispRing:
7567 16 tempitem.power=1;
7568 16 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7569 16 tempitem.misc1 = 3;
7570 16 break;
7571
7572 case iL2WhispRing:
7573 16 tempitem.power=0;
7574 16 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7575 16 tempitem.misc1 = 3;
7576 16 break;
7577
7578 case iL2Ladder:
7579 case iBow:
7580 case iCByrna:
7581 48 tempitem.power = 1;
7582 48 break;
7583 }
7584 4096 }
7585
7586
4/4
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 28928 times.
✓ Branch 2 taken 4080 times.
✓ Branch 3 taken 16 times.
33024 if(s_version < 9 && i==iClock)
7587 {
7588 16 tempitem.misc1 = get_bit(deprecated_rules, qr_TEMPCLOCKS_DEP) ? 256 : 0;
7589 16 }
7590
7591 //add the misc flag for bomb
7592
4/4
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 28928 times.
✓ Branch 2 taken 4080 times.
✓ Branch 3 taken 16 times.
33024 if(s_version < 10 && tempitem.family == itype_bomb)
7593 {
7594 16 tempitem.flags = (tempitem.flags & ~ITEM_FLAG1) | (get_qr(qr_LONGBOMBBOOM_DEP) ? ITEM_FLAG1 : 0);
7595 16 }
7596
7597
4/4
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 28928 times.
✓ Branch 2 taken 4064 times.
✓ Branch 3 taken 32 times.
33024 if(s_version < 11 && tempitem.family == itype_triforcepiece)
7598 {
7599 32 tempitem.flags = (tempitem.fam_type ? ITEM_GAMEDATA : 0);
7600 32 tempitem.playsound = (tempitem.fam_type ? WAV_SCALE : WAV_CLEARED);
7601 32 }
7602
7603
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 12) // June 2007: More Misc. attributes.
7604 {
7605
5/5
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 4016 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 16 times.
4096 switch(i)
7606 {
7607 case iFBrang:
7608 16 tempitem.misc4 |= shFIREBALL|shSWORD|shMAGIC;
7609
7610 //fallthrough
7611 case iMBrang:
7612 32 tempitem.misc3 |= shSWORD|shMAGIC;
7613
7614 //fallthrough
7615 case iHookshot:
7616 case iLongshot:
7617 //fallthrough
7618 64 tempitem.misc3 |= shFIREBALL;
7619
7620 case iBrang:
7621 80 tempitem.misc3 |= shBRANG|shROCK|shARROW;
7622 80 break;
7623 }
7624
7625
16/16
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 48 times.
✓ Branch 4 taken 32 times.
✓ Branch 5 taken 48 times.
✓ Branch 6 taken 48 times.
✓ Branch 7 taken 1740 times.
✓ Branch 8 taken 16 times.
✓ Branch 9 taken 16 times.
✓ Branch 10 taken 16 times.
✓ Branch 11 taken 16 times.
✓ Branch 12 taken 16 times.
✓ Branch 13 taken 64 times.
✓ Branch 14 taken 32 times.
✓ Branch 15 taken 1956 times.
4096 switch(tempitem.family)
7626 {
7627 case itype_hoverboots:
7628 16 tempitem.usesound = WAV_ZN1HOVER;
7629 16 break;
7630
7631 case itype_wand:
7632 16 tempitem.usesound = WAV_WAND;
7633 16 break;
7634
7635 case itype_book:
7636 16 tempitem.usesound = WAV_FIRE;
7637 16 break;
7638
7639 case itype_arrow:
7640 48 tempitem.usesound = WAV_ARROW;
7641 48 break;
7642
7643 case itype_hookshot:
7644 32 tempitem.usesound = WAV_HOOKSHOT;
7645 32 break;
7646
7647 case itype_brang:
7648 48 tempitem.usesound = WAV_BRANG;
7649 48 break;
7650
7651 case itype_shield:
7652 48 tempitem.usesound = WAV_CHINK;
7653 48 break;
7654
7655 case itype_sword:
7656 1740 tempitem.usesound = WAV_SWORD;
7657 1740 break;
7658
7659 case itype_whistle:
7660 16 tempitem.usesound = WAV_WHISTLE;
7661 16 break;
7662
7663 case itype_hammer:
7664 16 tempitem.usesound = WAV_HAMMER;
7665 16 break;
7666
7667 case itype_divinefire:
7668 16 tempitem.usesound = WAV_ZN1DIVINEFIRE;
7669 16 break;
7670
7671 case itype_divineescape:
7672 16 tempitem.usesound = WAV_ZN1DIVINEESCAPE;
7673 16 break;
7674
7675 case itype_divineprotection:
7676 16 tempitem.usesound = WAV_ZN1DIVINEPROTECTION1;
7677 16 break;
7678
7679 case itype_bomb:
7680 case itype_sbomb:
7681 case itype_quakescroll:
7682 case itype_quakescroll2:
7683 64 tempitem.usesound = WAV_BOMB;
7684 64 break;
7685
7686 case itype_spinscroll:
7687 case itype_spinscroll2:
7688 32 tempitem.usesound = WAV_ZN1SPINATTACK;
7689 32 break;
7690 }
7691 4096 }
7692
7693
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 13) // July 2007
7694 {
7695
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4080 times.
4096 if(tempitem.family == itype_whistle)
7696 {
7697 16 tempitem.misc1 = (tempitem.power==2 ? 4 : 3);
7698 16 tempitem.power = 1;
7699 16 tempitem.flags|=ITEM_FLAG1;
7700 16 }
7701
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4064 times.
4080 else if(tempitem.family == itype_wand)
7702 16 tempitem.flags|=ITEM_FLAG1;
7703
2/2
✓ Branch 0 taken 4048 times.
✓ Branch 1 taken 16 times.
4064 else if(tempitem.family == itype_book)
7704 {
7705 16 tempitem.flags|=ITEM_FLAG1;
7706 16 tempitem.power = 2;
7707 16 }
7708 4096 }
7709
7710
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 14) // August 2007
7711 {
7712
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 4064 times.
4096 if(tempitem.family == itype_fairy)
7713 {
7714 32 tempitem.usesound = WAV_SCALE;
7715
7716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(tempitem.fam_type)
7717 32 tempitem.misc3=50;
7718 32 }
7719
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 32 times.
4064 else if(tempitem.family == itype_potion)
7720 {
7721 32 tempitem.flags |= ITEM_GAINOLD;
7722 32 }
7723 4096 }
7724
7725
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 17) // November 2007
7726 {
7727
3/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 4064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
4096 if(tempitem.family == itype_candle && !tempitem.wpn3)
7728 {
7729 tempitem.wpn3 = wFIRE;
7730 }
7731
4/4
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 4048 times.
✓ Branch 2 taken 32 times.
✓ Branch 3 taken 16 times.
4096 else if(tempitem.family == itype_arrow && tempitem.power>4)
7732 {
7733 16 tempitem.flags|=ITEM_FLAG1;
7734 16 }
7735 4096 }
7736
7737
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 18) // New Year's Eve 2007
7738 {
7739
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4080 times.
4096 if(tempitem.family == itype_whistle)
7740 16 tempitem.misc2 = 8; // Use the Whistle warp ring
7741
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4064 times.
4080 else if(tempitem.family == itype_bait)
7742 16 tempitem.misc1 = 768; // Frames until it goes
7743
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 32 times.
4064 else if(tempitem.family == itype_triforcepiece)
7744 {
7745
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
32 if(tempitem.flags & ITEM_GAMEDATA)
7746 {
7747 16 tempitem.misc2 = 1; // Cutscene 1
7748 16 tempitem.flags |= ITEM_FLAG1; // Side Warp Out
7749 16 }
7750 32 }
7751 4096 }
7752
7753
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 19) // January 2008
7754 {
7755
2/2
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
4096 if(tempitem.family == itype_divineprotection)
7756 {
7757 16 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+1)?ITEM_FLAG3:0;
7758 16 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+2)?ITEM_FLAG4:0;
7759 16 }
7760 4096 }
7761
7762
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 20) // October 2008
7763 {
7764
2/2
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
4096 if(tempitem.family == itype_divineprotection)
7765 {
7766 16 tempitem.wpn6=wDIVINEPROTECTION2A;
7767 16 tempitem.wpn7=wDIVINEPROTECTION2B;
7768 16 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7769 16 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7770 16 tempitem.wpn5 = iwDivineProtectionShieldFront;
7771 16 tempitem.wpn10 = iwDivineProtectionShieldBack;
7772 16 }
7773 4096 }
7774
7775
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 21) // November 2008
7776 {
7777
1/2
✓ Branch 0 taken 4096 times.
✗ Branch 1 not taken.
4096 if(tempitem.flags & 0x0100) // ITEM_SLASH
7778 {
7779 tempitem.flags &= ~0x0100;
7780
7781 if(tempitem.family == itype_sword ||
7782 tempitem.family == itype_wand ||
7783 tempitem.family == itype_candle ||
7784 tempitem.family == itype_cbyrna)
7785 {
7786 tempitem.flags |= ITEM_FLAG4;
7787 }
7788 }
7789 4096 }
7790
7791
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 22) // September 2009
7792 {
7793
4/4
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4064 times.
4096 if(tempitem.family == itype_sbomb || tempitem.family == itype_bomb)
7794 {
7795 32 tempitem.misc3 = tempitem.power/2;
7796 32 }
7797 4096 }
7798
7799
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 23) // March 2011
7800 {
7801
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4080 times.
4096 if(tempitem.family == itype_divinefire)
7802 16 tempitem.wpn5 = wFIRE;
7803
2/2
✓ Branch 0 taken 4064 times.
✓ Branch 1 taken 16 times.
4080 else if(tempitem.family == itype_book)
7804 16 tempitem.wpn2 = wFIRE;
7805 4096 }
7806
7807 // Version 25: Bomb bags were acting as though "super bombs also" was checked
7808 // whether it was or not, and a lot of existing quests depended on the
7809 // incorrect behavior.
7810
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 25) // January 2012
7811 {
7812
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 64 times.
4096 if(tempitem.family == itype_bombbag)
7813 64 tempitem.flags |= 16;
7814
7815
2/2
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
4096 if(tempitem.family == itype_divinefire)
7816 16 tempitem.flags |= ITEM_FLAG3; // Sideview gravity flag
7817 4096 }
7818
7819
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( version < 0x254) //Nuke greyed-out flags/values from <=2.53, in case they are used in 2.54/2.55
7820 {
7821
60/60
✓ Branch 0 taken 7811 times.
✓ Branch 1 taken 277 times.
✓ Branch 2 taken 274 times.
✓ Branch 3 taken 222 times.
✓ Branch 4 taken 138 times.
✓ Branch 5 taken 93 times.
✓ Branch 6 taken 184 times.
✓ Branch 7 taken 183 times.
✓ Branch 8 taken 107 times.
✓ Branch 9 taken 302 times.
✓ Branch 10 taken 276 times.
✓ Branch 11 taken 183 times.
✓ Branch 12 taken 283 times.
✓ Branch 13 taken 184 times.
✓ Branch 14 taken 92 times.
✓ Branch 15 taken 184 times.
✓ Branch 16 taken 107 times.
✓ Branch 17 taken 92 times.
✓ Branch 18 taken 279 times.
✓ Branch 19 taken 93 times.
✓ Branch 20 taken 94 times.
✓ Branch 21 taken 184 times.
✓ Branch 22 taken 92 times.
✓ Branch 23 taken 93 times.
✓ Branch 24 taken 92 times.
✓ Branch 25 taken 92 times.
✓ Branch 26 taken 92 times.
✓ Branch 27 taken 107 times.
✓ Branch 28 taken 92 times.
✓ Branch 29 taken 93 times.
✓ Branch 30 taken 92 times.
✓ Branch 31 taken 93 times.
✓ Branch 32 taken 184 times.
✓ Branch 33 taken 368 times.
✓ Branch 34 taken 94 times.
✓ Branch 35 taken 92 times.
✓ Branch 36 taken 168 times.
✓ Branch 37 taken 368 times.
✓ Branch 38 taken 92 times.
✓ Branch 39 taken 92 times.
✓ Branch 40 taken 92 times.
✓ Branch 41 taken 92 times.
✓ Branch 42 taken 92 times.
✓ Branch 43 taken 185 times.
✓ Branch 44 taken 184 times.
✓ Branch 45 taken 92 times.
✓ Branch 46 taken 277 times.
✓ Branch 47 taken 278 times.
✓ Branch 48 taken 372 times.
✓ Branch 49 taken 92 times.
✓ Branch 50 taken 92 times.
✓ Branch 51 taken 92 times.
✓ Branch 52 taken 92 times.
✓ Branch 53 taken 92 times.
✓ Branch 54 taken 93 times.
✓ Branch 55 taken 2541 times.
✓ Branch 56 taken 983 times.
✓ Branch 57 taken 277 times.
✓ Branch 58 taken 1135 times.
✓ Branch 59 taken 2617 times.
23808 switch(tempitem.family)
7822 {
7823 case itype_sword:
7824 {
7825 7811 tempitem.flags &= ~(ITEM_FLAG5);
7826 7811 tempitem.misc3 = 0;
7827 7811 tempitem.misc4 = 0;
7828 7811 tempitem.misc5 = 0;
7829 7811 tempitem.misc6 = 0;
7830 7811 tempitem.misc7 = 0;
7831 7811 tempitem.misc8 = 0;
7832 7811 tempitem.misc9 = 0;
7833 7811 tempitem.misc10 = 0;
7834 7811 tempitem.wpn4 = 0;
7835 7811 tempitem.wpn5 = 0;
7836 7811 tempitem.wpn6 = 0;
7837 7811 tempitem.wpn7 = 0;
7838 7811 tempitem.wpn8 = 0;
7839 7811 tempitem.wpn9 = 0;
7840 7811 tempitem.wpn10 = 0;
7841 7811 break;
7842 }
7843 case itype_brang:
7844 {
7845 277 tempitem.flags &= ~(ITEM_FLAG4 | ITEM_FLAG5);
7846 277 tempitem.misc2 = 0;
7847 277 tempitem.misc5 = 0;
7848 277 tempitem.misc6 = 0;
7849 277 tempitem.misc7 = 0;
7850 277 tempitem.misc8 = 0;
7851 277 tempitem.misc9 = 0;
7852 277 tempitem.misc10 = 0;
7853 277 tempitem.wpn4 = 0;
7854 277 tempitem.wpn5 = 0;
7855 277 tempitem.wpn6 = 0;
7856 277 tempitem.wpn7 = 0;
7857 277 tempitem.wpn8 = 0;
7858 277 tempitem.wpn9 = 0;
7859 277 tempitem.wpn10 = 0;
7860 277 break;
7861 }
7862 case itype_arrow:
7863 {
7864 274 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7865 274 tempitem.misc2 = 0;
7866 274 tempitem.misc3 = 0;
7867 274 tempitem.misc4 = 0;
7868 274 tempitem.misc5 = 0;
7869 274 tempitem.misc6 = 0;
7870 274 tempitem.misc7 = 0;
7871 274 tempitem.misc8 = 0;
7872 274 tempitem.misc9 = 0;
7873 274 tempitem.misc10 = 0;
7874 274 tempitem.wpn4 = 0;
7875 274 tempitem.wpn5 = 0;
7876 274 tempitem.wpn6 = 0;
7877 274 tempitem.wpn7 = 0;
7878 274 tempitem.wpn8 = 0;
7879 274 tempitem.wpn9 = 0;
7880 274 tempitem.wpn10 = 0;
7881 274 break;
7882 }
7883 case itype_candle:
7884 {
7885 222 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG5);
7886 222 tempitem.misc1 = 0;
7887 222 tempitem.misc2 = 0;
7888 222 tempitem.misc3 = 0;
7889 222 tempitem.misc4 = 0;
7890 222 tempitem.misc5 = 0;
7891 222 tempitem.misc6 = 0;
7892 222 tempitem.misc7 = 0;
7893 222 tempitem.misc8 = 0;
7894 222 tempitem.misc9 = 0;
7895 222 tempitem.misc10 = 0;
7896 222 tempitem.wpn4 = 0;
7897 222 tempitem.wpn5 = 0;
7898 222 tempitem.wpn6 = 0;
7899 222 tempitem.wpn7 = 0;
7900 222 tempitem.wpn8 = 0;
7901 222 tempitem.wpn9 = 0;
7902 222 tempitem.wpn10 = 0;
7903 222 break;
7904 }
7905 case itype_whistle:
7906 {
7907 138 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7908 138 tempitem.misc3 = 0;
7909 138 tempitem.misc4 = 0;
7910 138 tempitem.misc5 = 0;
7911 138 tempitem.misc6 = 0;
7912 138 tempitem.misc7 = 0;
7913 138 tempitem.misc8 = 0;
7914 138 tempitem.misc9 = 0;
7915 138 tempitem.misc10 = 0;
7916 138 tempitem.wpn2 = 0;
7917 138 tempitem.wpn3 = 0;
7918 138 tempitem.wpn4 = 0;
7919 138 tempitem.wpn5 = 0;
7920 138 tempitem.wpn6 = 0;
7921 138 tempitem.wpn7 = 0;
7922 138 tempitem.wpn8 = 0;
7923 138 tempitem.wpn9 = 0;
7924 138 tempitem.wpn10 = 0;
7925 138 break;
7926 }
7927 case itype_bait:
7928 {
7929 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7930 93 tempitem.misc2 = 0;
7931 93 tempitem.misc3 = 0;
7932 93 tempitem.misc4 = 0;
7933 93 tempitem.misc5 = 0;
7934 93 tempitem.misc6 = 0;
7935 93 tempitem.misc7 = 0;
7936 93 tempitem.misc8 = 0;
7937 93 tempitem.misc9 = 0;
7938 93 tempitem.misc10 = 0;
7939 93 tempitem.wpn2 = 0;
7940 93 tempitem.wpn3 = 0;
7941 93 tempitem.wpn4 = 0;
7942 93 tempitem.wpn5 = 0;
7943 93 tempitem.wpn6 = 0;
7944 93 tempitem.wpn7 = 0;
7945 93 tempitem.wpn8 = 0;
7946 93 tempitem.wpn9 = 0;
7947 93 tempitem.wpn10 = 0;
7948 93 break;
7949 }
7950 case itype_letter:
7951 {
7952 184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7953 184 tempitem.misc1 = 0;
7954 184 tempitem.misc2 = 0;
7955 184 tempitem.misc3 = 0;
7956 184 tempitem.misc4 = 0;
7957 184 tempitem.misc5 = 0;
7958 184 tempitem.misc6 = 0;
7959 184 tempitem.misc7 = 0;
7960 184 tempitem.misc8 = 0;
7961 184 tempitem.misc9 = 0;
7962 184 tempitem.misc10 = 0;
7963 184 tempitem.wpn = 0;
7964 184 tempitem.wpn2 = 0;
7965 184 tempitem.wpn3 = 0;
7966 184 tempitem.wpn4 = 0;
7967 184 tempitem.wpn5 = 0;
7968 184 tempitem.wpn6 = 0;
7969 184 tempitem.wpn7 = 0;
7970 184 tempitem.wpn8 = 0;
7971 184 tempitem.wpn9 = 0;
7972 184 tempitem.wpn10 = 0;
7973 184 break;
7974 }
7975 case itype_potion:
7976 {
7977 183 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7978 183 tempitem.misc3 = 0;
7979 183 tempitem.misc4 = 0;
7980 183 tempitem.misc5 = 0;
7981 183 tempitem.misc6 = 0;
7982 183 tempitem.misc7 = 0;
7983 183 tempitem.misc8 = 0;
7984 183 tempitem.misc9 = 0;
7985 183 tempitem.misc10 = 0;
7986 183 tempitem.wpn = 0;
7987 183 tempitem.wpn2 = 0;
7988 183 tempitem.wpn3 = 0;
7989 183 tempitem.wpn4 = 0;
7990 183 tempitem.wpn5 = 0;
7991 183 tempitem.wpn6 = 0;
7992 183 tempitem.wpn7 = 0;
7993 183 tempitem.wpn8 = 0;
7994 183 tempitem.wpn9 = 0;
7995 183 tempitem.wpn10 = 0;
7996 183 break;
7997 }
7998 case itype_wand:
7999 {
8000 107 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
8001 107 tempitem.misc1 = 0;
8002 107 tempitem.misc2 = 0;
8003 107 tempitem.misc3 = 0;
8004 107 tempitem.misc4 = 0;
8005 107 tempitem.misc5 = 0;
8006 107 tempitem.misc6 = 0;
8007 107 tempitem.misc7 = 0;
8008 107 tempitem.misc8 = 0;
8009 107 tempitem.misc9 = 0;
8010 107 tempitem.misc10 = 0;
8011 107 tempitem.wpn4 = 0;
8012 107 tempitem.wpn5 = 0;
8013 107 tempitem.wpn6 = 0;
8014 107 tempitem.wpn7 = 0;
8015 107 tempitem.wpn8 = 0;
8016 107 tempitem.wpn9 = 0;
8017 107 tempitem.wpn10 = 0;
8018 107 break;
8019 }
8020 case itype_ring:
8021 {
8022 302 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8023 302 tempitem.misc2 = 0;
8024 302 tempitem.misc3 = 0;
8025 302 tempitem.misc4 = 0;
8026 302 tempitem.misc5 = 0;
8027 302 tempitem.misc6 = 0;
8028 302 tempitem.misc7 = 0;
8029 302 tempitem.misc8 = 0;
8030 302 tempitem.misc9 = 0;
8031 302 tempitem.misc10 = 0;
8032 302 tempitem.wpn = 0;
8033 302 tempitem.wpn2 = 0;
8034 302 tempitem.wpn3 = 0;
8035 302 tempitem.wpn4 = 0;
8036 302 tempitem.wpn5 = 0;
8037 302 tempitem.wpn6 = 0;
8038 302 tempitem.wpn7 = 0;
8039 302 tempitem.wpn8 = 0;
8040 302 tempitem.wpn9 = 0;
8041 302 tempitem.wpn10 = 0;
8042 302 break;
8043 }
8044 case itype_wallet:
8045 {
8046 276 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8047 276 tempitem.misc3 = 0;
8048 276 tempitem.misc4 = 0;
8049 276 tempitem.misc5 = 0;
8050 276 tempitem.misc6 = 0;
8051 276 tempitem.misc7 = 0;
8052 276 tempitem.misc8 = 0;
8053 276 tempitem.misc9 = 0;
8054 276 tempitem.misc10 = 0;
8055 276 tempitem.wpn = 0;
8056 276 tempitem.wpn2 = 0;
8057 276 tempitem.wpn3 = 0;
8058 276 tempitem.wpn4 = 0;
8059 276 tempitem.wpn5 = 0;
8060 276 tempitem.wpn6 = 0;
8061 276 tempitem.wpn7 = 0;
8062 276 tempitem.wpn8 = 0;
8063 276 tempitem.wpn9 = 0;
8064 276 tempitem.wpn10 = 0;
8065 276 break;
8066 }
8067 case itype_amulet:
8068 {
8069 183 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8070 183 tempitem.misc1 = 0;
8071 183 tempitem.misc2 = 0;
8072 183 tempitem.misc3 = 0;
8073 183 tempitem.misc4 = 0;
8074 183 tempitem.misc5 = 0;
8075 183 tempitem.misc6 = 0;
8076 183 tempitem.misc7 = 0;
8077 183 tempitem.misc8 = 0;
8078 183 tempitem.misc9 = 0;
8079 183 tempitem.misc10 = 0;
8080 183 tempitem.wpn = 0;
8081 183 tempitem.wpn2 = 0;
8082 183 tempitem.wpn3 = 0;
8083 183 tempitem.wpn4 = 0;
8084 183 tempitem.wpn5 = 0;
8085 183 tempitem.wpn6 = 0;
8086 183 tempitem.wpn7 = 0;
8087 183 tempitem.wpn8 = 0;
8088 183 tempitem.wpn9 = 0;
8089 183 tempitem.wpn10 = 0;
8090 183 break;
8091 }
8092 case itype_shield:
8093 {
8094 283 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8095 283 tempitem.misc3 = 0;
8096 283 tempitem.misc4 = 0;
8097 283 tempitem.misc5 = 0;
8098 283 tempitem.misc6 = 0;
8099 283 tempitem.misc7 = 0;
8100 283 tempitem.misc8 = 0;
8101 283 tempitem.misc9 = 0;
8102 283 tempitem.misc10 = 0;
8103 283 tempitem.wpn = 0;
8104 283 tempitem.wpn2 = 0;
8105 283 tempitem.wpn3 = 0;
8106 283 tempitem.wpn4 = 0;
8107 283 tempitem.wpn5 = 0;
8108 283 tempitem.wpn6 = 0;
8109 283 tempitem.wpn7 = 0;
8110 283 tempitem.wpn8 = 0;
8111 283 tempitem.wpn9 = 0;
8112 283 tempitem.wpn10 = 0;
8113 283 break;
8114 }
8115 case itype_bow:
8116 {
8117 184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8118 184 tempitem.misc1 = 0;
8119 184 tempitem.misc2 = 0;
8120 184 tempitem.misc3 = 0;
8121 184 tempitem.misc4 = 0;
8122 184 tempitem.misc5 = 0;
8123 184 tempitem.misc6 = 0;
8124 184 tempitem.misc7 = 0;
8125 184 tempitem.misc8 = 0;
8126 184 tempitem.misc9 = 0;
8127 184 tempitem.misc10 = 0;
8128 184 tempitem.wpn = 0;
8129 184 tempitem.wpn2 = 0;
8130 184 tempitem.wpn3 = 0;
8131 184 tempitem.wpn4 = 0;
8132 184 tempitem.wpn5 = 0;
8133 184 tempitem.wpn6 = 0;
8134 184 tempitem.wpn7 = 0;
8135 184 tempitem.wpn8 = 0;
8136 184 tempitem.wpn9 = 0;
8137 184 tempitem.wpn10 = 0;
8138 184 break;
8139 }
8140 case itype_raft:
8141 {
8142 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8143 92 tempitem.misc1 = 0;
8144 92 tempitem.misc2 = 0;
8145 92 tempitem.misc3 = 0;
8146 92 tempitem.misc4 = 0;
8147 92 tempitem.misc5 = 0;
8148 92 tempitem.misc6 = 0;
8149 92 tempitem.misc7 = 0;
8150 92 tempitem.misc8 = 0;
8151 92 tempitem.misc9 = 0;
8152 92 tempitem.misc10 = 0;
8153 92 tempitem.wpn = 0;
8154 92 tempitem.wpn2 = 0;
8155 92 tempitem.wpn3 = 0;
8156 92 tempitem.wpn4 = 0;
8157 92 tempitem.wpn5 = 0;
8158 92 tempitem.wpn6 = 0;
8159 92 tempitem.wpn7 = 0;
8160 92 tempitem.wpn8 = 0;
8161 92 tempitem.wpn9 = 0;
8162 92 tempitem.wpn10 = 0;
8163 92 break;
8164 }
8165 case itype_ladder:
8166 {
8167 184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8168 184 tempitem.misc1 = 0;
8169 184 tempitem.misc2 = 0;
8170 184 tempitem.misc3 = 0;
8171 184 tempitem.misc4 = 0;
8172 184 tempitem.misc5 = 0;
8173 184 tempitem.misc6 = 0;
8174 184 tempitem.misc7 = 0;
8175 184 tempitem.misc8 = 0;
8176 184 tempitem.misc9 = 0;
8177 184 tempitem.misc10 = 0;
8178 184 tempitem.wpn = 0;
8179 184 tempitem.wpn2 = 0;
8180 184 tempitem.wpn3 = 0;
8181 184 tempitem.wpn4 = 0;
8182 184 tempitem.wpn5 = 0;
8183 184 tempitem.wpn6 = 0;
8184 184 tempitem.wpn7 = 0;
8185 184 tempitem.wpn8 = 0;
8186 184 tempitem.wpn9 = 0;
8187 184 tempitem.wpn10 = 0;
8188 184 break;
8189 }
8190 case itype_book:
8191 {
8192 107 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8193 107 tempitem.misc1 = 0;
8194 107 tempitem.misc2 = 0;
8195 107 tempitem.misc3 = 0;
8196 107 tempitem.misc4 = 0;
8197 107 tempitem.misc5 = 0;
8198 107 tempitem.misc6 = 0;
8199 107 tempitem.misc7 = 0;
8200 107 tempitem.misc8 = 0;
8201 107 tempitem.misc9 = 0;
8202 107 tempitem.misc10 = 0;
8203 107 tempitem.wpn3 = 0;
8204 107 tempitem.wpn4 = 0;
8205 107 tempitem.wpn5 = 0;
8206 107 tempitem.wpn6 = 0;
8207 107 tempitem.wpn7 = 0;
8208 107 tempitem.wpn8 = 0;
8209 107 tempitem.wpn9 = 0;
8210 107 tempitem.wpn10 = 0;
8211 107 break;
8212 }
8213 case itype_magickey:
8214 {
8215 92 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8216 92 tempitem.misc1 = 0;
8217 92 tempitem.misc2 = 0;
8218 92 tempitem.misc3 = 0;
8219 92 tempitem.misc4 = 0;
8220 92 tempitem.misc5 = 0;
8221 92 tempitem.misc6 = 0;
8222 92 tempitem.misc7 = 0;
8223 92 tempitem.misc8 = 0;
8224 92 tempitem.misc9 = 0;
8225 92 tempitem.misc10 = 0;
8226 92 tempitem.wpn = 0;
8227 92 tempitem.wpn2 = 0;
8228 92 tempitem.wpn3 = 0;
8229 92 tempitem.wpn4 = 0;
8230 92 tempitem.wpn5 = 0;
8231 92 tempitem.wpn6 = 0;
8232 92 tempitem.wpn7 = 0;
8233 92 tempitem.wpn8 = 0;
8234 92 tempitem.wpn9 = 0;
8235 92 tempitem.wpn10 = 0;
8236 92 break;
8237 }
8238 case itype_bracelet:
8239 {
8240 279 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8241 279 tempitem.misc1 = 0;
8242 279 tempitem.misc2 = 0;
8243 279 tempitem.misc3 = 0;
8244 279 tempitem.misc4 = 0;
8245 279 tempitem.misc5 = 0;
8246 279 tempitem.misc6 = 0;
8247 279 tempitem.misc7 = 0;
8248 279 tempitem.misc8 = 0;
8249 279 tempitem.misc9 = 0;
8250 279 tempitem.misc10 = 0;
8251 279 tempitem.wpn = 0;
8252 279 tempitem.wpn2 = 0;
8253 279 tempitem.wpn3 = 0;
8254 279 tempitem.wpn4 = 0;
8255 279 tempitem.wpn5 = 0;
8256 279 tempitem.wpn6 = 0;
8257 279 tempitem.wpn7 = 0;
8258 279 tempitem.wpn8 = 0;
8259 279 tempitem.wpn9 = 0;
8260 279 tempitem.wpn10 = 0;
8261 279 break;
8262 }
8263 case itype_flippers:
8264 {
8265 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8266 93 tempitem.misc1 = 0;
8267 93 tempitem.misc2 = 0;
8268 93 tempitem.misc3 = 0;
8269 93 tempitem.misc4 = 0;
8270 93 tempitem.misc5 = 0;
8271 93 tempitem.misc6 = 0;
8272 93 tempitem.misc7 = 0;
8273 93 tempitem.misc8 = 0;
8274 93 tempitem.misc9 = 0;
8275 93 tempitem.misc10 = 0;
8276 93 tempitem.wpn = 0;
8277 93 tempitem.wpn2 = 0;
8278 93 tempitem.wpn3 = 0;
8279 93 tempitem.wpn4 = 0;
8280 93 tempitem.wpn5 = 0;
8281 93 tempitem.wpn6 = 0;
8282 93 tempitem.wpn7 = 0;
8283 93 tempitem.wpn8 = 0;
8284 93 tempitem.wpn9 = 0;
8285 93 tempitem.wpn10 = 0;
8286 93 break;
8287 }
8288 case itype_boots:
8289 {
8290 94 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8291 94 tempitem.misc1 = 0;
8292 94 tempitem.misc2 = 0;
8293 94 tempitem.misc3 = 0;
8294 94 tempitem.misc4 = 0;
8295 94 tempitem.misc5 = 0;
8296 94 tempitem.misc6 = 0;
8297 94 tempitem.misc7 = 0;
8298 94 tempitem.misc8 = 0;
8299 94 tempitem.misc9 = 0;
8300 94 tempitem.misc10 = 0;
8301 94 tempitem.wpn = 0;
8302 94 tempitem.wpn2 = 0;
8303 94 tempitem.wpn3 = 0;
8304 94 tempitem.wpn4 = 0;
8305 94 tempitem.wpn5 = 0;
8306 94 tempitem.wpn6 = 0;
8307 94 tempitem.wpn7 = 0;
8308 94 tempitem.wpn8 = 0;
8309 94 tempitem.wpn9 = 0;
8310 94 tempitem.wpn10 = 0;
8311 94 break;
8312 }
8313 case itype_hookshot:
8314 {
8315 184 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8316 184 tempitem.misc5 = 0;
8317 184 tempitem.misc6 = 0;
8318 184 tempitem.misc7 = 0;
8319 184 tempitem.misc8 = 0;
8320 184 tempitem.misc9 = 0;
8321 184 tempitem.misc10 = 0;
8322 184 tempitem.wpn5 = 0;
8323 184 tempitem.wpn6 = 0;
8324 184 tempitem.wpn7 = 0;
8325 184 tempitem.wpn8 = 0;
8326 184 tempitem.wpn9 = 0;
8327 184 tempitem.wpn10 = 0;
8328 184 break;
8329 }
8330 case itype_lens:
8331 {
8332 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8333 92 tempitem.misc2 = 0;
8334 92 tempitem.misc3 = 0;
8335 92 tempitem.misc4 = 0;
8336 92 tempitem.misc5 = 0;
8337 92 tempitem.misc6 = 0;
8338 92 tempitem.misc7 = 0;
8339 92 tempitem.misc8 = 0;
8340 92 tempitem.misc9 = 0;
8341 92 tempitem.misc10 = 0;
8342 92 tempitem.wpn = 0;
8343 92 tempitem.wpn2 = 0;
8344 92 tempitem.wpn3 = 0;
8345 92 tempitem.wpn4 = 0;
8346 92 tempitem.wpn5 = 0;
8347 92 tempitem.wpn6 = 0;
8348 92 tempitem.wpn7 = 0;
8349 92 tempitem.wpn8 = 0;
8350 92 tempitem.wpn9 = 0;
8351 92 tempitem.wpn10 = 0;
8352 92 break;
8353 }
8354 case itype_hammer:
8355 {
8356 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8357 93 tempitem.misc1 = 0;
8358 93 tempitem.misc2 = 0;
8359 93 tempitem.misc3 = 0;
8360 93 tempitem.misc4 = 0;
8361 93 tempitem.misc5 = 0;
8362 93 tempitem.misc6 = 0;
8363 93 tempitem.misc7 = 0;
8364 93 tempitem.misc8 = 0;
8365 93 tempitem.misc9 = 0;
8366 93 tempitem.misc10 = 0;
8367 93 tempitem.wpn3 = 0;
8368 93 tempitem.wpn4 = 0;
8369 93 tempitem.wpn5 = 0;
8370 93 tempitem.wpn6 = 0;
8371 93 tempitem.wpn7 = 0;
8372 93 tempitem.wpn8 = 0;
8373 93 tempitem.wpn9 = 0;
8374 93 tempitem.wpn10 = 0;
8375 93 break;
8376 }
8377 case itype_divinefire:
8378 {
8379 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG4 | ITEM_FLAG5);
8380 92 tempitem.misc3 = 0;
8381 92 tempitem.misc4 = 0;
8382 92 tempitem.misc5 = 0;
8383 92 tempitem.misc6 = 0;
8384 92 tempitem.misc7 = 0;
8385 92 tempitem.misc8 = 0;
8386 92 tempitem.misc9 = 0;
8387 92 tempitem.misc10 = 0;
8388 92 tempitem.wpn6 = 0;
8389 92 tempitem.wpn7 = 0;
8390 92 tempitem.wpn8 = 0;
8391 92 tempitem.wpn9 = 0;
8392 92 tempitem.wpn10 = 0;
8393 92 break;
8394 }
8395 case itype_divineescape:
8396 {
8397 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8398 92 tempitem.misc2 = 0;
8399 92 tempitem.misc3 = 0;
8400 92 tempitem.misc4 = 0;
8401 92 tempitem.misc5 = 0;
8402 92 tempitem.misc6 = 0;
8403 92 tempitem.misc7 = 0;
8404 92 tempitem.misc8 = 0;
8405 92 tempitem.misc9 = 0;
8406 92 tempitem.misc10 = 0;
8407 92 tempitem.wpn = 0;
8408 92 tempitem.wpn2 = 0;
8409 92 tempitem.wpn3 = 0;
8410 92 tempitem.wpn4 = 0;
8411 92 tempitem.wpn5 = 0;
8412 92 tempitem.wpn6 = 0;
8413 92 tempitem.wpn7 = 0;
8414 92 tempitem.wpn8 = 0;
8415 92 tempitem.wpn9 = 0;
8416 92 tempitem.wpn10 = 0;
8417 92 break;
8418 }
8419 case itype_divineprotection:
8420 {
8421 92 tempitem.flags &= ~ (ITEM_FLAG5);
8422 92 tempitem.misc2 = 0;
8423 92 tempitem.misc3 = 0;
8424 92 tempitem.misc4 = 0;
8425 92 tempitem.misc5 = 0;
8426 92 tempitem.misc6 = 0;
8427 92 tempitem.misc7 = 0;
8428 92 tempitem.misc8 = 0;
8429 92 tempitem.misc9 = 0;
8430 92 tempitem.misc10 = 0;
8431 92 break;
8432 }
8433 case itype_bomb:
8434 {
8435 107 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8436 107 tempitem.misc4 = 0;
8437 107 tempitem.misc5 = 0;
8438 107 tempitem.misc6 = 0;
8439 107 tempitem.misc7 = 0;
8440 107 tempitem.misc8 = 0;
8441 107 tempitem.misc9 = 0;
8442 107 tempitem.misc10 = 0;
8443 107 tempitem.wpn3 = 0;
8444 107 tempitem.wpn4 = 0;
8445 107 tempitem.wpn5 = 0;
8446 107 tempitem.wpn6 = 0;
8447 107 tempitem.wpn7 = 0;
8448 107 tempitem.wpn8 = 0;
8449 107 tempitem.wpn9 = 0;
8450 107 tempitem.wpn10 = 0;
8451 107 break;
8452 }
8453 case itype_sbomb:
8454 {
8455 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8456 92 tempitem.misc4 = 0;
8457 92 tempitem.misc5 = 0;
8458 92 tempitem.misc6 = 0;
8459 92 tempitem.misc7 = 0;
8460 92 tempitem.misc8 = 0;
8461 92 tempitem.misc9 = 0;
8462 92 tempitem.misc10 = 0;
8463 92 tempitem.wpn3 = 0;
8464 92 tempitem.wpn4 = 0;
8465 92 tempitem.wpn5 = 0;
8466 92 tempitem.wpn6 = 0;
8467 92 tempitem.wpn7 = 0;
8468 92 tempitem.wpn8 = 0;
8469 92 tempitem.wpn9 = 0;
8470 92 tempitem.wpn10 = 0;
8471 92 break;
8472 }
8473 case itype_clock:
8474 {
8475 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8476 93 tempitem.misc2 = 0;
8477 93 tempitem.misc3 = 0;
8478 93 tempitem.misc4 = 0;
8479 93 tempitem.misc5 = 0;
8480 93 tempitem.misc6 = 0;
8481 93 tempitem.misc7 = 0;
8482 93 tempitem.misc8 = 0;
8483 93 tempitem.misc9 = 0;
8484 93 tempitem.misc10 = 0;
8485 93 tempitem.wpn = 0;
8486 93 tempitem.wpn2 = 0;
8487 93 tempitem.wpn3 = 0;
8488 93 tempitem.wpn4 = 0;
8489 93 tempitem.wpn5 = 0;
8490 93 tempitem.wpn6 = 0;
8491 93 tempitem.wpn7 = 0;
8492 93 tempitem.wpn8 = 0;
8493 93 tempitem.wpn9 = 0;
8494 93 tempitem.wpn10 = 0;
8495 93 break;
8496 }
8497 case itype_key:
8498 {
8499 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8500 92 tempitem.misc1 = 0;
8501 92 tempitem.misc2 = 0;
8502 92 tempitem.misc3 = 0;
8503 92 tempitem.misc4 = 0;
8504 92 tempitem.misc5 = 0;
8505 92 tempitem.misc6 = 0;
8506 92 tempitem.misc7 = 0;
8507 92 tempitem.misc8 = 0;
8508 92 tempitem.misc9 = 0;
8509 92 tempitem.misc10 = 0;
8510 92 tempitem.wpn = 0;
8511 92 tempitem.wpn2 = 0;
8512 92 tempitem.wpn3 = 0;
8513 92 tempitem.wpn4 = 0;
8514 92 tempitem.wpn5 = 0;
8515 92 tempitem.wpn6 = 0;
8516 92 tempitem.wpn7 = 0;
8517 92 tempitem.wpn8 = 0;
8518 92 tempitem.wpn9 = 0;
8519 92 tempitem.wpn10 = 0;
8520 92 break;
8521 }
8522 case itype_magiccontainer:
8523 {
8524 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8525 93 tempitem.misc1 = 0;
8526 93 tempitem.misc2 = 0;
8527 93 tempitem.misc3 = 0;
8528 93 tempitem.misc4 = 0;
8529 93 tempitem.misc5 = 0;
8530 93 tempitem.misc6 = 0;
8531 93 tempitem.misc7 = 0;
8532 93 tempitem.misc8 = 0;
8533 93 tempitem.misc9 = 0;
8534 93 tempitem.misc10 = 0;
8535 93 tempitem.wpn = 0;
8536 93 tempitem.wpn2 = 0;
8537 93 tempitem.wpn3 = 0;
8538 93 tempitem.wpn4 = 0;
8539 93 tempitem.wpn5 = 0;
8540 93 tempitem.wpn6 = 0;
8541 93 tempitem.wpn7 = 0;
8542 93 tempitem.wpn8 = 0;
8543 93 tempitem.wpn9 = 0;
8544 93 tempitem.wpn10 = 0;
8545 93 break;
8546 }
8547 case itype_triforcepiece:
8548 {
8549 184 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8550 184 tempitem.misc3 = 0;
8551 184 tempitem.misc4 = 0;
8552 184 tempitem.misc5 = 0;
8553 184 tempitem.misc6 = 0;
8554 184 tempitem.misc7 = 0;
8555 184 tempitem.misc8 = 0;
8556 184 tempitem.misc9 = 0;
8557 184 tempitem.misc10 = 0;
8558 184 tempitem.wpn = 0;
8559 184 tempitem.wpn2 = 0;
8560 184 tempitem.wpn3 = 0;
8561 184 tempitem.wpn4 = 0;
8562 184 tempitem.wpn5 = 0;
8563 184 tempitem.wpn6 = 0;
8564 184 tempitem.wpn7 = 0;
8565 184 tempitem.wpn8 = 0;
8566 184 tempitem.wpn9 = 0;
8567 184 tempitem.wpn10 = 0;
8568 184 break;
8569 }
8570 case itype_map: case itype_compass: case itype_bosskey:
8571 {
8572 277 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8573 277 tempitem.misc1 = 0;
8574 277 tempitem.misc2 = 0;
8575 277 tempitem.misc3 = 0;
8576 277 tempitem.misc4 = 0;
8577 277 tempitem.misc5 = 0;
8578 277 tempitem.misc6 = 0;
8579 277 tempitem.misc7 = 0;
8580 277 tempitem.misc8 = 0;
8581 277 tempitem.misc9 = 0;
8582 277 tempitem.misc10 = 0;
8583 277 tempitem.wpn = 0;
8584 277 tempitem.wpn2 = 0;
8585 277 tempitem.wpn3 = 0;
8586 277 tempitem.wpn4 = 0;
8587 277 tempitem.wpn5 = 0;
8588 277 tempitem.wpn6 = 0;
8589 277 tempitem.wpn7 = 0;
8590 277 tempitem.wpn8 = 0;
8591 277 tempitem.wpn9 = 0;
8592 277 tempitem.wpn10 = 0;
8593 277 break;
8594 }
8595 case itype_quiver:
8596 {
8597 368 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8598 368 tempitem.misc3 = 0;
8599 368 tempitem.misc4 = 0;
8600 368 tempitem.misc5 = 0;
8601 368 tempitem.misc6 = 0;
8602 368 tempitem.misc7 = 0;
8603 368 tempitem.misc8 = 0;
8604 368 tempitem.misc9 = 0;
8605 368 tempitem.misc10 = 0;
8606 368 tempitem.wpn = 0;
8607 368 tempitem.wpn2 = 0;
8608 368 tempitem.wpn3 = 0;
8609 368 tempitem.wpn4 = 0;
8610 368 tempitem.wpn5 = 0;
8611 368 tempitem.wpn6 = 0;
8612 368 tempitem.wpn7 = 0;
8613 368 tempitem.wpn8 = 0;
8614 368 tempitem.wpn9 = 0;
8615 368 tempitem.wpn10 = 0;
8616 368 break;
8617 }
8618 case itype_lkey:
8619 {
8620 94 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8621 94 tempitem.misc1 = 0;
8622 94 tempitem.misc2 = 0;
8623 94 tempitem.misc3 = 0;
8624 94 tempitem.misc4 = 0;
8625 94 tempitem.misc5 = 0;
8626 94 tempitem.misc6 = 0;
8627 94 tempitem.misc7 = 0;
8628 94 tempitem.misc8 = 0;
8629 94 tempitem.misc9 = 0;
8630 94 tempitem.misc10 = 0;
8631 94 tempitem.wpn = 0;
8632 94 tempitem.wpn2 = 0;
8633 94 tempitem.wpn3 = 0;
8634 94 tempitem.wpn4 = 0;
8635 94 tempitem.wpn5 = 0;
8636 94 tempitem.wpn6 = 0;
8637 94 tempitem.wpn7 = 0;
8638 94 tempitem.wpn8 = 0;
8639 94 tempitem.wpn9 = 0;
8640 94 tempitem.wpn10 = 0;
8641 94 break;
8642 }
8643 case itype_cbyrna:
8644 {
8645 92 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
8646 92 tempitem.misc4 = 0;
8647 92 tempitem.misc5 = 0;
8648 92 tempitem.misc6 = 0;
8649 92 tempitem.misc7 = 0;
8650 92 tempitem.misc8 = 0;
8651 92 tempitem.misc9 = 0;
8652 92 tempitem.misc10 = 0;
8653 92 tempitem.wpn6 = 0;
8654 92 tempitem.wpn7 = 0;
8655 92 tempitem.wpn8 = 0;
8656 92 tempitem.wpn9 = 0;
8657 92 tempitem.wpn10 = 0;
8658 92 break;
8659 }
8660 case itype_rupee: case itype_arrowammo:
8661 {
8662 1135 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8663 1135 tempitem.misc1 = 0;
8664 1135 tempitem.misc2 = 0;
8665 1135 tempitem.misc3 = 0;
8666 1135 tempitem.misc4 = 0;
8667 1135 tempitem.misc5 = 0;
8668 1135 tempitem.misc6 = 0;
8669 1135 tempitem.misc7 = 0;
8670 1135 tempitem.misc8 = 0;
8671 1135 tempitem.misc9 = 0;
8672 1135 tempitem.misc10 = 0;
8673 1135 tempitem.wpn = 0;
8674 1135 tempitem.wpn2 = 0;
8675 1135 tempitem.wpn3 = 0;
8676 1135 tempitem.wpn4 = 0;
8677 1135 tempitem.wpn5 = 0;
8678 1135 tempitem.wpn6 = 0;
8679 1135 tempitem.wpn7 = 0;
8680 1135 tempitem.wpn8 = 0;
8681 1135 tempitem.wpn9 = 0;
8682 1135 tempitem.wpn10 = 0;
8683 1135 break;
8684 }
8685 case itype_fairy:
8686 {
8687 168 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8688 168 tempitem.misc4 = 0;
8689 168 tempitem.misc5 = 0;
8690 168 tempitem.misc6 = 0;
8691 168 tempitem.misc7 = 0;
8692 168 tempitem.misc8 = 0;
8693 168 tempitem.misc9 = 0;
8694 168 tempitem.misc10 = 0;
8695 168 tempitem.wpn = 0;
8696 168 tempitem.wpn2 = 0;
8697 168 tempitem.wpn3 = 0;
8698 168 tempitem.wpn4 = 0;
8699 168 tempitem.wpn5 = 0;
8700 168 tempitem.wpn6 = 0;
8701 168 tempitem.wpn7 = 0;
8702 168 tempitem.wpn8 = 0;
8703 168 tempitem.wpn9 = 0;
8704 168 tempitem.wpn10 = 0;
8705 168 break;
8706 }
8707 case itype_magic: case itype_heart: case itype_heartcontainer: case itype_heartpiece: case itype_killem: case itype_bombammo:
8708 {
8709 983 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8710 983 tempitem.misc1 = 0;
8711 983 tempitem.misc2 = 0;
8712 983 tempitem.misc3 = 0;
8713 983 tempitem.misc4 = 0;
8714 983 tempitem.misc5 = 0;
8715 983 tempitem.misc6 = 0;
8716 983 tempitem.misc7 = 0;
8717 983 tempitem.misc8 = 0;
8718 983 tempitem.misc9 = 0;
8719 983 tempitem.misc10 = 0;
8720 983 tempitem.wpn = 0;
8721 983 tempitem.wpn2 = 0;
8722 983 tempitem.wpn3 = 0;
8723 983 tempitem.wpn4 = 0;
8724 983 tempitem.wpn5 = 0;
8725 983 tempitem.wpn6 = 0;
8726 983 tempitem.wpn7 = 0;
8727 983 tempitem.wpn8 = 0;
8728 983 tempitem.wpn9 = 0;
8729 983 tempitem.wpn10 = 0;
8730 983 break;
8731 }
8732 case itype_bombbag:
8733 {
8734 368 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8735 368 tempitem.misc3 = 0;
8736 368 tempitem.misc4 = 0;
8737 368 tempitem.misc5 = 0;
8738 368 tempitem.misc6 = 0;
8739 368 tempitem.misc7 = 0;
8740 368 tempitem.misc8 = 0;
8741 368 tempitem.misc9 = 0;
8742 368 tempitem.misc10 = 0;
8743 368 tempitem.wpn = 0;
8744 368 tempitem.wpn2 = 0;
8745 368 tempitem.wpn3 = 0;
8746 368 tempitem.wpn4 = 0;
8747 368 tempitem.wpn5 = 0;
8748 368 tempitem.wpn6 = 0;
8749 368 tempitem.wpn7 = 0;
8750 368 tempitem.wpn8 = 0;
8751 368 tempitem.wpn9 = 0;
8752 368 tempitem.wpn10 = 0;
8753 368 break;
8754 }
8755 case itype_rocs:
8756 {
8757 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8758 92 tempitem.misc1 = 0;
8759 92 tempitem.misc2 = 0;
8760 92 tempitem.misc3 = 0;
8761 92 tempitem.misc4 = 0;
8762 92 tempitem.misc5 = 0;
8763 92 tempitem.misc6 = 0;
8764 92 tempitem.misc7 = 0;
8765 92 tempitem.misc8 = 0;
8766 92 tempitem.misc9 = 0;
8767 92 tempitem.misc10 = 0;
8768 92 tempitem.wpn = 0;
8769 92 tempitem.wpn2 = 0;
8770 92 tempitem.wpn3 = 0;
8771 92 tempitem.wpn4 = 0;
8772 92 tempitem.wpn5 = 0;
8773 92 tempitem.wpn6 = 0;
8774 92 tempitem.wpn7 = 0;
8775 92 tempitem.wpn8 = 0;
8776 92 tempitem.wpn9 = 0;
8777 92 tempitem.wpn10 = 0;
8778 92 break;
8779 }
8780 case itype_hoverboots:
8781 {
8782 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8783 92 tempitem.misc2 = 0;
8784 92 tempitem.misc3 = 0;
8785 92 tempitem.misc4 = 0;
8786 92 tempitem.misc5 = 0;
8787 92 tempitem.misc6 = 0;
8788 92 tempitem.misc7 = 0;
8789 92 tempitem.misc8 = 0;
8790 92 tempitem.misc9 = 0;
8791 92 tempitem.misc10 = 0;
8792 92 tempitem.wpn2 = 0;
8793 92 tempitem.wpn3 = 0;
8794 92 tempitem.wpn4 = 0;
8795 92 tempitem.wpn5 = 0;
8796 92 tempitem.wpn6 = 0;
8797 92 tempitem.wpn7 = 0;
8798 92 tempitem.wpn8 = 0;
8799 92 tempitem.wpn9 = 0;
8800 92 tempitem.wpn10 = 0;
8801 92 break;
8802 }
8803 case itype_spinscroll:
8804 {
8805 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8806 92 tempitem.misc2 = 0;
8807 92 tempitem.misc3 = 0;
8808 92 tempitem.misc4 = 0;
8809 92 tempitem.misc5 = 0;
8810 92 tempitem.misc6 = 0;
8811 92 tempitem.misc7 = 0;
8812 92 tempitem.misc8 = 0;
8813 92 tempitem.misc9 = 0;
8814 92 tempitem.misc10 = 0;
8815 92 tempitem.wpn = 0;
8816 92 tempitem.wpn2 = 0;
8817 92 tempitem.wpn3 = 0;
8818 92 tempitem.wpn4 = 0;
8819 92 tempitem.wpn5 = 0;
8820 92 tempitem.wpn6 = 0;
8821 92 tempitem.wpn7 = 0;
8822 92 tempitem.wpn8 = 0;
8823 92 tempitem.wpn9 = 0;
8824 92 tempitem.wpn10 = 0;
8825 92 break;
8826 }
8827 case itype_crossscroll:
8828 {
8829 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8830 92 tempitem.misc1 = 0;
8831 92 tempitem.misc2 = 0;
8832 92 tempitem.misc3 = 0;
8833 92 tempitem.misc4 = 0;
8834 92 tempitem.misc5 = 0;
8835 92 tempitem.misc6 = 0;
8836 92 tempitem.misc7 = 0;
8837 92 tempitem.misc8 = 0;
8838 92 tempitem.misc9 = 0;
8839 92 tempitem.misc10 = 0;
8840 92 tempitem.wpn = 0;
8841 92 tempitem.wpn2 = 0;
8842 92 tempitem.wpn3 = 0;
8843 92 tempitem.wpn4 = 0;
8844 92 tempitem.wpn5 = 0;
8845 92 tempitem.wpn6 = 0;
8846 92 tempitem.wpn7 = 0;
8847 92 tempitem.wpn8 = 0;
8848 92 tempitem.wpn9 = 0;
8849 92 tempitem.wpn10 = 0;
8850 92 break;
8851 }
8852 case itype_quakescroll:
8853 {
8854 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8855 92 tempitem.misc3 = 0;
8856 92 tempitem.misc4 = 0;
8857 92 tempitem.misc5 = 0;
8858 92 tempitem.misc6 = 0;
8859 92 tempitem.misc7 = 0;
8860 92 tempitem.misc8 = 0;
8861 92 tempitem.misc9 = 0;
8862 92 tempitem.misc10 = 0;
8863 92 tempitem.wpn = 0;
8864 92 tempitem.wpn2 = 0;
8865 92 tempitem.wpn3 = 0;
8866 92 tempitem.wpn4 = 0;
8867 92 tempitem.wpn5 = 0;
8868 92 tempitem.wpn6 = 0;
8869 92 tempitem.wpn7 = 0;
8870 92 tempitem.wpn8 = 0;
8871 92 tempitem.wpn9 = 0;
8872 92 tempitem.wpn10 = 0;
8873 92 break;
8874 }
8875 case itype_whispring:
8876 {
8877 185 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8878 185 tempitem.misc2 = 0;
8879 185 tempitem.misc3 = 0;
8880 185 tempitem.misc4 = 0;
8881 185 tempitem.misc5 = 0;
8882 185 tempitem.misc6 = 0;
8883 185 tempitem.misc7 = 0;
8884 185 tempitem.misc8 = 0;
8885 185 tempitem.misc9 = 0;
8886 185 tempitem.misc10 = 0;
8887 185 tempitem.wpn = 0;
8888 185 tempitem.wpn2 = 0;
8889 185 tempitem.wpn3 = 0;
8890 185 tempitem.wpn4 = 0;
8891 185 tempitem.wpn5 = 0;
8892 185 tempitem.wpn6 = 0;
8893 185 tempitem.wpn7 = 0;
8894 185 tempitem.wpn8 = 0;
8895 185 tempitem.wpn9 = 0;
8896 185 tempitem.wpn10 = 0;
8897 185 break;
8898 }
8899 case itype_chargering:
8900 {
8901 184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8902 184 tempitem.misc3 = 0;
8903 184 tempitem.misc4 = 0;
8904 184 tempitem.misc5 = 0;
8905 184 tempitem.misc6 = 0;
8906 184 tempitem.misc7 = 0;
8907 184 tempitem.misc8 = 0;
8908 184 tempitem.misc9 = 0;
8909 184 tempitem.misc10 = 0;
8910 184 tempitem.wpn = 0;
8911 184 tempitem.wpn2 = 0;
8912 184 tempitem.wpn3 = 0;
8913 184 tempitem.wpn4 = 0;
8914 184 tempitem.wpn5 = 0;
8915 184 tempitem.wpn6 = 0;
8916 184 tempitem.wpn7 = 0;
8917 184 tempitem.wpn8 = 0;
8918 184 tempitem.wpn9 = 0;
8919 184 tempitem.wpn10 = 0;
8920 184 break;
8921 }
8922 case itype_perilscroll:
8923 {
8924 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8925 92 tempitem.misc2 = 0;
8926 92 tempitem.misc3 = 0;
8927 92 tempitem.misc4 = 0;
8928 92 tempitem.misc5 = 0;
8929 92 tempitem.misc6 = 0;
8930 92 tempitem.misc7 = 0;
8931 92 tempitem.misc8 = 0;
8932 92 tempitem.misc9 = 0;
8933 92 tempitem.misc10 = 0;
8934 92 tempitem.wpn = 0;
8935 92 tempitem.wpn2 = 0;
8936 92 tempitem.wpn3 = 0;
8937 92 tempitem.wpn4 = 0;
8938 92 tempitem.wpn5 = 0;
8939 92 tempitem.wpn6 = 0;
8940 92 tempitem.wpn7 = 0;
8941 92 tempitem.wpn8 = 0;
8942 92 tempitem.wpn9 = 0;
8943 92 tempitem.wpn10 = 0;
8944 92 break;
8945 }
8946 case itype_wealthmedal:
8947 {
8948 277 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8949 277 tempitem.misc2 = 0;
8950 277 tempitem.misc3 = 0;
8951 277 tempitem.misc4 = 0;
8952 277 tempitem.misc5 = 0;
8953 277 tempitem.misc6 = 0;
8954 277 tempitem.misc7 = 0;
8955 277 tempitem.misc8 = 0;
8956 277 tempitem.misc9 = 0;
8957 277 tempitem.misc10 = 0;
8958 277 tempitem.wpn = 0;
8959 277 tempitem.wpn2 = 0;
8960 277 tempitem.wpn3 = 0;
8961 277 tempitem.wpn4 = 0;
8962 277 tempitem.wpn5 = 0;
8963 277 tempitem.wpn6 = 0;
8964 277 tempitem.wpn7 = 0;
8965 277 tempitem.wpn8 = 0;
8966 277 tempitem.wpn9 = 0;
8967 277 tempitem.wpn10 = 0;
8968 277 break;
8969 }
8970 case itype_heartring:
8971 {
8972 278 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8973 278 tempitem.misc3 = 0;
8974 278 tempitem.misc4 = 0;
8975 278 tempitem.misc5 = 0;
8976 278 tempitem.misc6 = 0;
8977 278 tempitem.misc7 = 0;
8978 278 tempitem.misc8 = 0;
8979 278 tempitem.misc9 = 0;
8980 278 tempitem.misc10 = 0;
8981 278 tempitem.wpn = 0;
8982 278 tempitem.wpn2 = 0;
8983 278 tempitem.wpn3 = 0;
8984 278 tempitem.wpn4 = 0;
8985 278 tempitem.wpn5 = 0;
8986 278 tempitem.wpn6 = 0;
8987 278 tempitem.wpn7 = 0;
8988 278 tempitem.wpn8 = 0;
8989 278 tempitem.wpn9 = 0;
8990 278 tempitem.wpn10 = 0;
8991 278 break;
8992 }
8993 case itype_magicring:
8994 {
8995 372 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8996 372 tempitem.misc3 = 0;
8997 372 tempitem.misc4 = 0;
8998 372 tempitem.misc5 = 0;
8999 372 tempitem.misc6 = 0;
9000 372 tempitem.misc7 = 0;
9001 372 tempitem.misc8 = 0;
9002 372 tempitem.misc9 = 0;
9003 372 tempitem.misc10 = 0;
9004 372 tempitem.wpn = 0;
9005 372 tempitem.wpn2 = 0;
9006 372 tempitem.wpn3 = 0;
9007 372 tempitem.wpn4 = 0;
9008 372 tempitem.wpn5 = 0;
9009 372 tempitem.wpn6 = 0;
9010 372 tempitem.wpn7 = 0;
9011 372 tempitem.wpn8 = 0;
9012 372 tempitem.wpn9 = 0;
9013 372 tempitem.wpn10 = 0;
9014 372 break;
9015 }
9016 case itype_spinscroll2:
9017 {
9018 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9019 92 tempitem.misc2 = 0;
9020 92 tempitem.misc3 = 0;
9021 92 tempitem.misc4 = 0;
9022 92 tempitem.misc5 = 0;
9023 92 tempitem.misc6 = 0;
9024 92 tempitem.misc7 = 0;
9025 92 tempitem.misc8 = 0;
9026 92 tempitem.misc9 = 0;
9027 92 tempitem.misc10 = 0;
9028 92 tempitem.wpn = 0;
9029 92 tempitem.wpn2 = 0;
9030 92 tempitem.wpn3 = 0;
9031 92 tempitem.wpn4 = 0;
9032 92 tempitem.wpn5 = 0;
9033 92 tempitem.wpn6 = 0;
9034 92 tempitem.wpn7 = 0;
9035 92 tempitem.wpn8 = 0;
9036 92 tempitem.wpn9 = 0;
9037 92 tempitem.wpn10 = 0;
9038 92 break;
9039 }
9040 case itype_quakescroll2:
9041 {
9042 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9043 92 tempitem.misc3 = 0;
9044 92 tempitem.misc4 = 0;
9045 92 tempitem.misc5 = 0;
9046 92 tempitem.misc6 = 0;
9047 92 tempitem.misc7 = 0;
9048 92 tempitem.misc8 = 0;
9049 92 tempitem.misc9 = 0;
9050 92 tempitem.misc10 = 0;
9051 92 tempitem.wpn = 0;
9052 92 tempitem.wpn2 = 0;
9053 92 tempitem.wpn3 = 0;
9054 92 tempitem.wpn4 = 0;
9055 92 tempitem.wpn5 = 0;
9056 92 tempitem.wpn6 = 0;
9057 92 tempitem.wpn7 = 0;
9058 92 tempitem.wpn8 = 0;
9059 92 tempitem.wpn9 = 0;
9060 92 tempitem.wpn10 = 0;
9061 92 break;
9062 }
9063 case itype_agony:
9064 {
9065 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9066 92 tempitem.misc2 = 0;
9067 92 tempitem.misc3 = 0;
9068 92 tempitem.misc4 = 0;
9069 92 tempitem.misc5 = 0;
9070 92 tempitem.misc6 = 0;
9071 92 tempitem.misc7 = 0;
9072 92 tempitem.misc8 = 0;
9073 92 tempitem.misc9 = 0;
9074 92 tempitem.misc10 = 0;
9075 92 tempitem.wpn = 0;
9076 92 tempitem.wpn2 = 0;
9077 92 tempitem.wpn3 = 0;
9078 92 tempitem.wpn4 = 0;
9079 92 tempitem.wpn5 = 0;
9080 92 tempitem.wpn6 = 0;
9081 92 tempitem.wpn7 = 0;
9082 92 tempitem.wpn8 = 0;
9083 92 tempitem.wpn9 = 0;
9084 92 tempitem.wpn10 = 0;
9085 92 break;
9086 }
9087 case itype_stompboots:
9088 {
9089 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9090 92 tempitem.misc1 = 0;
9091 92 tempitem.misc2 = 0;
9092 92 tempitem.misc3 = 0;
9093 92 tempitem.misc4 = 0;
9094 92 tempitem.misc5 = 0;
9095 92 tempitem.misc6 = 0;
9096 92 tempitem.misc7 = 0;
9097 92 tempitem.misc8 = 0;
9098 92 tempitem.misc9 = 0;
9099 92 tempitem.misc10 = 0;
9100 92 tempitem.wpn = 0;
9101 92 tempitem.wpn2 = 0;
9102 92 tempitem.wpn3 = 0;
9103 92 tempitem.wpn4 = 0;
9104 92 tempitem.wpn5 = 0;
9105 92 tempitem.wpn6 = 0;
9106 92 tempitem.wpn7 = 0;
9107 92 tempitem.wpn8 = 0;
9108 92 tempitem.wpn9 = 0;
9109 92 tempitem.wpn10 = 0;
9110 92 break;
9111 }
9112 case itype_whimsicalring:
9113 {
9114 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9115 92 tempitem.misc2 = 0;
9116 92 tempitem.misc3 = 0;
9117 92 tempitem.misc4 = 0;
9118 92 tempitem.misc5 = 0;
9119 92 tempitem.misc6 = 0;
9120 92 tempitem.misc7 = 0;
9121 92 tempitem.misc8 = 0;
9122 92 tempitem.misc9 = 0;
9123 92 tempitem.misc10 = 0;
9124 92 tempitem.wpn = 0;
9125 92 tempitem.wpn2 = 0;
9126 92 tempitem.wpn3 = 0;
9127 92 tempitem.wpn4 = 0;
9128 92 tempitem.wpn5 = 0;
9129 92 tempitem.wpn6 = 0;
9130 92 tempitem.wpn7 = 0;
9131 92 tempitem.wpn8 = 0;
9132 92 tempitem.wpn9 = 0;
9133 92 tempitem.wpn10 = 0;
9134 92 break;
9135 }
9136 case itype_perilring:
9137 {
9138 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9139 93 tempitem.misc2 = 0;
9140 93 tempitem.misc3 = 0;
9141 93 tempitem.misc4 = 0;
9142 93 tempitem.misc5 = 0;
9143 93 tempitem.misc6 = 0;
9144 93 tempitem.misc7 = 0;
9145 93 tempitem.misc8 = 0;
9146 93 tempitem.misc9 = 0;
9147 93 tempitem.misc10 = 0;
9148 93 tempitem.wpn = 0;
9149 93 tempitem.wpn2 = 0;
9150 93 tempitem.wpn3 = 0;
9151 93 tempitem.wpn4 = 0;
9152 93 tempitem.wpn5 = 0;
9153 93 tempitem.wpn6 = 0;
9154 93 tempitem.wpn7 = 0;
9155 93 tempitem.wpn8 = 0;
9156 93 tempitem.wpn9 = 0;
9157 93 tempitem.wpn10 = 0;
9158 93 break;
9159 }
9160 case itype_custom1: case itype_custom2: case itype_custom3: case itype_custom4: case itype_custom5:
9161 case itype_custom6: case itype_custom7: case itype_custom8: case itype_custom9: case itype_custom10:
9162 case itype_custom11: case itype_custom12: case itype_custom13: case itype_custom14: case itype_custom15:
9163 case itype_custom16: case itype_custom17: case itype_custom18: case itype_custom19: case itype_custom20:
9164 case itype_bowandarrow: case itype_letterpotion: case itype_misc:
9165 {
9166 2541 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9167 2541 tempitem.misc1 = 0;
9168 2541 tempitem.misc2 = 0;
9169 2541 tempitem.misc3 = 0;
9170 2541 tempitem.misc4 = 0;
9171 2541 tempitem.misc5 = 0;
9172 2541 tempitem.misc6 = 0;
9173 2541 tempitem.misc7 = 0;
9174 2541 tempitem.misc8 = 0;
9175 2541 tempitem.misc9 = 0;
9176 2541 tempitem.misc10 = 0;
9177 2541 tempitem.wpn = 0;
9178 2541 tempitem.wpn2 = 0;
9179 2541 tempitem.wpn3 = 0;
9180 2541 tempitem.wpn4 = 0;
9181 2541 tempitem.wpn5 = 0;
9182 2541 tempitem.wpn6 = 0;
9183 2541 tempitem.wpn7 = 0;
9184 2541 tempitem.wpn8 = 0;
9185 2541 tempitem.wpn9 = 0;
9186 2541 tempitem.wpn10 = 0;
9187 2541 break;
9188 }
9189 }
9190 23808 }
9191 //Port quest rules to items
9192
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version <= 31)
9193 {
9194
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 23701 times.
23808 if(tempitem.family == itype_bomb)
9195 {
9196
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 90 times.
107 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9197 90 else tempitem.flags &= ~ ITEM_FLAG2;
9198 107 }
9199
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23609 times.
23701 else if(tempitem.family == itype_sbomb)
9200 {
9201
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 75 times.
92 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9202 75 else tempitem.flags &= ~ ITEM_FLAG2;
9203 92 }
9204
9205
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 23332 times.
23609 else if(tempitem.family == itype_brang)
9206 {
9207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 277 times.
277 if ( get_qr(qr_BRANGPICKUP) ) tempitem.flags |= ITEM_FLAG4;
9208 277 else tempitem.flags &= ~ ITEM_FLAG4;
9209 277 }
9210
2/2
✓ Branch 0 taken 23225 times.
✓ Branch 1 taken 107 times.
23332 else if(tempitem.family == itype_wand)
9211 {
9212
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 105 times.
107 if ( get_qr(qr_NOWANDMELEE) ) tempitem.flags |= ITEM_FLAG3;
9213 105 else tempitem.flags &= ~ ITEM_FLAG3;
9214 107 }
9215 23808 }
9216
9217 //Port quest rules to items
9218
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version <= 37)
9219 {
9220
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 23715 times.
23808 if(tempitem.family == itype_flippers)
9221 {
9222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 if ( (get_qr(qr_NODIVING)) ) tempitem.flags |= ITEM_FLAG1;
9223 93 else tempitem.flags &= ~ ITEM_FLAG1;
9224 93 }
9225
2/2
✓ Branch 0 taken 15904 times.
✓ Branch 1 taken 7811 times.
23715 else if(tempitem.family == itype_sword)
9226 {
9227
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 7742 times.
7811 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9228 7742 else tempitem.flags &= ~ ITEM_FLAG5;
9229 7811 }
9230
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 15797 times.
15904 else if(tempitem.family == itype_wand)
9231 {
9232
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 104 times.
107 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9233 104 else tempitem.flags &= ~ ITEM_FLAG5;
9234 107 }
9235
4/4
✓ Branch 0 taken 15690 times.
✓ Branch 1 taken 107 times.
✓ Branch 2 taken 222 times.
✓ Branch 3 taken 15468 times.
15797 else if(tempitem.family == itype_book || tempitem.family == itype_candle)
9236 {
9237 //@Emily: What was qrFIREPROOFHERO2 again, and does that also need to enable this?
9238
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 257 times.
329 if ( (get_qr(qr_FIREPROOFHERO)) ) tempitem.flags |= ITEM_FLAG3;
9239 257 else tempitem.flags &= ~ ITEM_FLAG3;
9240 329 }
9241 23808 }
9242
9243
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version < 38)
9244 {
9245
4/4
✓ Branch 0 taken 23531 times.
✓ Branch 1 taken 277 times.
✓ Branch 2 taken 184 times.
✓ Branch 3 taken 23347 times.
23808 if(tempitem.family == itype_brang || tempitem.family == itype_hookshot)
9246 {
9247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
461 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9248 461 else tempitem.flags &= ~ITEM_FLAG4;
9249
9250
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 450 times.
461 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags |= ITEM_FLAG5 | ITEM_FLAG6;
9251 450 else tempitem.flags &= ~(ITEM_FLAG5|ITEM_FLAG6);
9252 461 }
9253
2/2
✓ Branch 0 taken 23073 times.
✓ Branch 1 taken 274 times.
23347 else if(tempitem.family == itype_arrow)
9254 {
9255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274 times.
274 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9256 274 else tempitem.flags &= ~ITEM_FLAG4;
9257
9258
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 270 times.
274 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags &= ~ITEM_FLAG2;
9259 270 else tempitem.flags |= ITEM_FLAG2;
9260 274 }
9261 23808 }
9262
9263
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version < 39)
9264 {
9265
6/6
✓ Branch 0 taken 23716 times.
✓ Branch 1 taken 92 times.
✓ Branch 2 taken 23609 times.
✓ Branch 3 taken 107 times.
✓ Branch 4 taken 222 times.
✓ Branch 5 taken 23387 times.
23808 if(tempitem.family == itype_divinefire || tempitem.family == itype_book || tempitem.family == itype_candle)
9266 {
9267
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 409 times.
421 if(get_qr(qr_TEMPCANDLELIGHT)) tempitem.flags |= ITEM_FLAG5;
9268 409 else tempitem.flags &= ~ITEM_FLAG5;
9269 421 }
9270
2/2
✓ Branch 0 taken 183 times.
✓ Branch 1 taken 23204 times.
23387 else if(tempitem.family == itype_potion)
9271 {
9272
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 159 times.
183 if(get_qr(qr_NONBUBBLEMEDICINE))
9273 {
9274 24 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9275 24 }
9276 else
9277 {
9278 159 tempitem.flags |= ITEM_FLAG3;
9279
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 74 times.
159 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9280 74 else tempitem.flags &= ~ITEM_FLAG4;
9281 }
9282 183 }
9283
2/2
✓ Branch 0 taken 23020 times.
✓ Branch 1 taken 184 times.
23204 else if(tempitem.family == itype_triforcepiece)
9284 {
9285
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 154 times.
184 if(get_qr(qr_NONBUBBLETRIFORCE))
9286 {
9287 30 tempitem.flags |= ITEM_FLAG3;
9288
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 24 times.
30 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9289 24 else tempitem.flags &= ~ITEM_FLAG4;
9290 30 }
9291 else
9292 {
9293 154 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9294 }
9295 184 }
9296 23808 }
9297
9298
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version < 40)
9299 {
9300
4/4
✓ Branch 0 taken 23506 times.
✓ Branch 1 taken 302 times.
✓ Branch 2 taken 93 times.
✓ Branch 3 taken 23413 times.
23808 if(tempitem.family == itype_ring || tempitem.family == itype_perilring)
9301 {
9302
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 348 times.
395 if(get_qr(qr_RINGAFFECTDAMAGE))tempitem.flags |= ITEM_FLAG1;
9303 348 else tempitem.flags &= ~ITEM_FLAG1;
9304 395 }
9305
8/8
✓ Branch 0 taken 23191 times.
✓ Branch 1 taken 222 times.
✓ Branch 2 taken 15380 times.
✓ Branch 3 taken 7811 times.
✓ Branch 4 taken 15273 times.
✓ Branch 5 taken 107 times.
✓ Branch 6 taken 92 times.
✓ Branch 7 taken 15181 times.
23413 else if(tempitem.family == itype_candle || tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_cbyrna)
9306 {
9307
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 8151 times.
8232 if(get_qr(qr_SLASHFLIPFIX))tempitem.flags |= ITEM_FLAG8;
9308 8151 else tempitem.flags &= ~ITEM_FLAG8;
9309 8232 }
9310
6/6
✓ Branch 0 taken 15997 times.
✓ Branch 1 taken 7811 times.
✓ Branch 2 taken 15890 times.
✓ Branch 3 taken 107 times.
✓ Branch 4 taken 93 times.
✓ Branch 5 taken 15797 times.
23808 if(tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_hammer)
9311 {
9312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8011 times.
8011 if(get_qr(qr_NOITEMMELEE))tempitem.flags |= ITEM_FLAG7;
9313 8011 else tempitem.flags &= ~ITEM_FLAG7;
9314 8011 }
9315
2/2
✓ Branch 0 taken 15705 times.
✓ Branch 1 taken 92 times.
15797 else if(tempitem.family == itype_cbyrna)
9316 {
9317 92 tempitem.flags |= ITEM_FLAG7;
9318 92 }
9319 23808 }
9320
9321
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version < 41 )
9322 {
9323
2/2
✓ Branch 0 taken 15997 times.
✓ Branch 1 taken 7811 times.
23808 if(tempitem.family == itype_sword)
9324 {
9325
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 7742 times.
7811 if(get_qr(qr_SWORDMIRROR))tempitem.flags |= ITEM_FLAG9;
9326 7742 else tempitem.flags &= ~ITEM_FLAG9;
9327
9328
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 7742 times.
7811 if(get_qr(qr_SLOWCHARGINGWALK))tempitem.flags |= ITEM_FLAG10;
9329 7742 else tempitem.flags &= ~ITEM_FLAG10;
9330 7811 }
9331 23808 }
9332
9333
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version < 42 )
9334 {
9335
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 23701 times.
23808 if(tempitem.family == itype_wand)
9336 {
9337
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 105 times.
107 if(get_qr(qr_NOWANDMELEE))tempitem.flags |= ITEM_FLAG3;
9338 105 else tempitem.flags &= ~ITEM_FLAG3;
9339
9340 107 tempitem.flags &= ~ITEM_FLAG6;
9341 107 }
9342
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 23608 times.
23701 else if(tempitem.family == itype_hammer)
9343 {
9344 93 tempitem.flags &= ~ITEM_FLAG3;
9345 93 }
9346
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23516 times.
23608 else if(tempitem.family == itype_cbyrna)
9347 {
9348 92 tempitem.flags |= ITEM_FLAG3;
9349
9350 92 tempitem.flags &= ~ITEM_FLAG6;
9351 92 }
9352
2/2
✓ Branch 0 taken 15705 times.
✓ Branch 1 taken 7811 times.
23516 else if(tempitem.family == itype_sword)
9353 {
9354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7811 times.
7811 if(get_qr(qr_MELEEMAGICCOST))tempitem.flags |= ITEM_FLAG6;
9355 7811 else tempitem.flags &= ~ITEM_FLAG6;
9356 7811 }
9357 23808 }
9358
9359
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version < 43 )
9360 {
9361
2/2
✓ Branch 0 taken 23670 times.
✓ Branch 1 taken 138 times.
23808 if(tempitem.family == itype_whistle)
9362 {
9363
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 135 times.
138 if(get_qr(qr_WHIRLWINDMIRROR))tempitem.flags |= ITEM_FLAG3;
9364 135 else tempitem.flags &= ~ITEM_FLAG3;
9365 138 }
9366 23808 }
9367
9368
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version < 45 )
9369 {
9370
2/2
✓ Branch 0 taken 23715 times.
✓ Branch 1 taken 93 times.
23808 if(tempitem.family == itype_flippers)
9371 {
9372 93 tempitem.misc1 = 50; //Dive length, default 50 frames -V
9373 93 tempitem.misc2 = 30; //Dive cooldown, default 30 frames -V
9374 93 }
9375 23808 }
9376
9377
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version < 46 )
9378 {
9379
2/2
✓ Branch 0 taken 23716 times.
✓ Branch 1 taken 92 times.
23808 if(tempitem.family == itype_raft)
9380 {
9381 92 tempitem.misc1 = 1; //Rafting speed modifier; default 1. Negative slows, positive speeds.
9382 92 }
9383 23808 }
9384
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if ( s_version < 34 ) //! set the default counter for older quests.
9385 {
9386
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 23733 times.
23808 if ( (tempitem.flags & ITEM_RUPEE_MAGIC) )
9387 {
9388 75 tempitem.cost_counter[0] = 1;
9389 75 }
9390 else
9391 {
9392
2/2
✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 19125 times.
23733 if(get_qr(qr_ENABLEMAGIC))
9393 4608 tempitem.cost_counter[0] = 4;
9394 else
9395 {
9396 19125 tempitem.cost_amount[0] = 0;
9397 19125 tempitem.cost_counter[0] = -1;
9398 }
9399 }
9400 23808 }
9401
9402
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if ( s_version < 35 ) //new Lens of Truth flags
9403 {
9404
2/2
✓ Branch 0 taken 23716 times.
✓ Branch 1 taken 92 times.
23808 if ( tempitem.family == itype_lens )
9405 {
9406
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 3 times.
92 if ( get_qr(qr_RAFTLENS) )
9407 {
9408 3 tempitem.flags |= ITEM_FLAG4;
9409 3 }
9410
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 52 times.
92 if ( get_qr(qr_LENSHINTS) )
9411 {
9412 52 tempitem.flags |= ITEM_FLAG1;
9413 52 }
9414
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 4 times.
92 if ( get_qr(qr_LENSSEESENEMIES) )
9415 {
9416 4 tempitem.flags |= ITEM_FLAG5;
9417 4 }
9418 92 }
9419 23808 }
9420
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if ( s_version < 44 ) //InitD Labels and Sprite Script Data
9421 {
9422
2/2
✓ Branch 0 taken 190464 times.
✓ Branch 1 taken 23808 times.
214272 for ( int32_t q = 0; q < 8; q++ )
9423 {
9424 190464 sprintf(tempitem.initD_label[q],"InitD[%d]",q);
9425 190464 sprintf(tempitem.weapon_initD_label[q],"InitD[%d]",q);
9426 190464 sprintf(tempitem.sprite_initD_label[q],"InitD[%d]",q);
9427 190464 tempitem.sprite_initiald[q] = 0;
9428 190464 }
9429
2/2
✓ Branch 0 taken 47616 times.
✓ Branch 1 taken 23808 times.
71424 for ( int32_t q = 0; q < 2; q++ ) tempitem.sprite_initiala[q] = 0;
9430 23808 tempitem.sprite_script = 0;
9431 23808 }
9432
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if ( s_version < 47 ) //InitD Labels and Sprite Script Data
9433 {
9434 23808 tempitem.pickupflag = 0;
9435 23808 }
9436
9437
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version < 51 )
9438 {
9439
2/2
✓ Branch 0 taken 23586 times.
✓ Branch 1 taken 222 times.
23808 if( tempitem.family == itype_candle )
9440 {
9441 222 tempitem.misc4 = 50; //Step speed
9442 222 }
9443 23808 }
9444
9445
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version < 52 )
9446 {
9447
2/2
✓ Branch 0 taken 23525 times.
✓ Branch 1 taken 283 times.
23808 if( tempitem.family == itype_shield )
9448 283 tempitem.flags |= ITEM_FLAG1; //'Block Front' flag
9449 23808 }
9450
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if(s_version < 53)
9451 {
9452
4/4
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 23335 times.
✓ Branch 2 taken 274 times.
✓ Branch 3 taken 92 times.
23808 switch(tempitem.family)
9453 {
9454 case itype_arrow:
9455 274 tempitem.cost_counter[1] = crARROWS;
9456 274 tempitem.cost_amount[1] = 1;
9457 274 break;
9458 case itype_bomb:
9459 107 tempitem.cost_counter[1] = crBOMBS;
9460 107 tempitem.cost_amount[1] = 1;
9461 107 break;
9462 case itype_sbomb:
9463 92 tempitem.cost_counter[1] = crSBOMBS;
9464 92 tempitem.cost_amount[1] = 1;
9465 92 break;
9466 default:
9467 23335 tempitem.cost_counter[1] = crNONE;
9468 23335 tempitem.cost_amount[1] = 0;
9469 23335 }
9470 23808 tempitem.magiccosttimer[1] = 0;
9471 23808 }
9472
2/2
✓ Branch 0 taken 7936 times.
✓ Branch 1 taken 25088 times.
33024 if( s_version < 54 )
9473 {
9474
2/2
✓ Branch 0 taken 24989 times.
✓ Branch 1 taken 99 times.
25088 if( tempitem.family == itype_flippers )
9475 99 tempitem.misc3 = INT_BTN_A; //'Block Front' flag
9476 25088 }
9477
2/2
✓ Branch 0 taken 7936 times.
✓ Branch 1 taken 25088 times.
33024 if(s_version < 55)
9478 {
9479
3/3
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 194 times.
✓ Branch 2 taken 24700 times.
25088 switch(tempitem.family)
9480 {
9481 case itype_spinscroll:
9482 case itype_quakescroll:
9483 194 tempitem.usesound2 = WAV_ZN1CHARGE;
9484 194 break;
9485 case itype_spinscroll2:
9486 case itype_quakescroll2:
9487 194 tempitem.usesound2 = WAV_ZN1CHARGE2;
9488 194 break;
9489 }
9490 25088 }
9491
2/2
✓ Branch 0 taken 7936 times.
✓ Branch 1 taken 25088 times.
33024 if(s_version < 56)
9492 {
9493
4/4
✓ Branch 0 taken 24645 times.
✓ Branch 1 taken 97 times.
✓ Branch 2 taken 234 times.
✓ Branch 3 taken 112 times.
25088 switch(tempitem.family)
9494 {
9495 case itype_divinefire:
9496
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 5 times.
97 SETFLAG(tempitem.flags, ITEM_FLAG9, version < 0x255); //Strong Fire
9497
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 81 times.
97 SETFLAG(tempitem.flags, ITEM_FLAG10, version < 0x250); //Magic Fire
9498 97 tempitem.flags |= ITEM_FLAG11; //Divine Fire
9499 97 break;
9500 case itype_candle:
9501
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 120 times.
234 SETFLAG(tempitem.flags, ITEM_FLAG9, tempitem.fam_type > 1); //Strong Fire
9502 234 tempitem.flags &= ~ITEM_FLAG10; //Magic Fire
9503 234 tempitem.flags &= ~ITEM_FLAG11; //Divine Fire
9504 234 break;
9505 case itype_book:
9506 112 tempitem.flags |= ITEM_FLAG9; //Strong Fire
9507 112 tempitem.flags |= ITEM_FLAG10; //Magic Fire
9508 112 tempitem.flags &= ~ITEM_FLAG11; //Divine Fire
9509 112 break;
9510 }
9511 25088 }
9512
9513
2/2
✓ Branch 0 taken 30880 times.
✓ Branch 1 taken 2144 times.
33024 if(tempitem.fam_type==0) // Always do this
9514 2144 tempitem.fam_type=1;
9515
9516 33024 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
9517 33024 }
9518
9519 129 return 0;
9520 129 }
9521
9522 static bool did_init_def_items = false;
9523 66240 void init_def_items()
9524 {
9525
2/2
✓ Branch 0 taken 66194 times.
✓ Branch 1 taken 46 times.
66240 if(did_init_def_items) return;
9526 46 did_init_def_items = true;
9527 46 default_items[3].cost_counter[1] = crBOMBS;
9528 46 default_items[13].cost_counter[1] = crARROWS;
9529 46 default_items[14].cost_counter[1] = crARROWS;
9530 46 default_items[48].cost_counter[1] = crSBOMBS;
9531 46 default_items[57].cost_counter[1] = crARROWS;
9532 66240 }
9533 66240 void reset_itembuf(itemdata *item, int32_t id)
9534 {
9535 66240 init_def_items();
9536
2/2
✓ Branch 0 taken 28250 times.
✓ Branch 1 taken 37990 times.
66240 if(id<iLast)
9537 {
9538 // Copy everything *EXCEPT* the tile, misc, cset, frames, speed, delay and ltm.
9539 37990 word tile = item->tile;
9540 37990 byte miscs = item->misc_flags, cset = item->csets, frames = item->frames, speed = item->speed, delay = item->delay;
9541 37990 int32_t ltm = item->ltm;
9542
9543 37990 memcpy(item,&default_items[id],sizeof(itemdata));
9544 37990 item->tile = tile;
9545 37990 item->misc_flags = miscs;
9546 37990 item->csets = cset;
9547 37990 item->frames = frames;
9548 37990 item->speed = speed;
9549 37990 item->delay = delay;
9550 37990 item->ltm = ltm;
9551 37990 }
9552 66240 }
9553
9554 15872 void reset_itemname(int32_t id)
9555 {
9556 15872 sprintf(item_string[id],"zz%03d",id);
9557
9558
2/2
✓ Branch 0 taken 7006 times.
✓ Branch 1 taken 8866 times.
15872 if(id < iLast)
9559 8866 strcpy(item_string[id],old_item_string[id]);
9560 15872 }
9561
9562 129 int32_t readweapons(PACKFILE *f, zquestheader *Header)
9563 {
9564 129 word weapons_to_read=MAXWPNS;
9565 int32_t dummy;
9566 byte padding;
9567 wpndata tempweapon;
9568 129 word s_version=0, s_cversion=0;
9569
9570
9571
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(Header->zelda_version < 0x186)
9572 {
9573 weapons_to_read=64;
9574 }
9575
9576
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(Header->zelda_version < 0x185)
9577 {
9578 weapons_to_read=32;
9579 }
9580
9581
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(Header->zelda_version > 0x192)
9582 {
9583 125 weapons_to_read=0;
9584
9585 //section version info
9586
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_version,f))
9587 {
9588 return qe_invalid;
9589 }
9590
9591 125 FFCore.quest_format[vWeaponSprites] = s_version;
9592
9593 //al_trace("Weapons version %d\n", s_version);
9594
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_cversion,f))
9595 {
9596 return qe_invalid;
9597 }
9598
9599 //section size
9600
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&dummy,f))
9601 {
9602 return qe_invalid;
9603 }
9604
9605 //finally... section data
9606
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&weapons_to_read,f))
9607 {
9608 return qe_invalid;
9609 }
9610
9611
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if (!(weapons_to_read >= 0 && weapons_to_read <= MAXWPNS))
9612 {
9613 return qe_invalid;
9614 }
9615 125 }
9616
9617
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version>2)
9618 {
9619
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 113 times.
29041 for(int32_t i=0; i<weapons_to_read; i++)
9620 {
9621 char tempname[64];
9622
9623
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!pfread(tempname, 64, f))
9624 {
9625 return qe_invalid;
9626 }
9627
9628 28928 weapon_string[i][0] = '\0';
9629 28928 strncat(weapon_string[i], tempname, 64 - 1);
9630 28928 }
9631
9632
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(s_version<4)
9633 {
9634 strcpy(weapon_string[iwHover],old_weapon_string[iwHover]);
9635 strcpy(weapon_string[wFIREMAGIC],old_weapon_string[wFIREMAGIC]);
9636 }
9637
9638
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(s_version<5)
9639 {
9640 strcpy(weapon_string[iwQuarterHearts],old_weapon_string[iwQuarterHearts]);
9641 }
9642
9643 /*
9644 if (s_version<6)
9645 {
9646 strcpy(weapon_string[iwSideRaft],old_weapon_string[iwSideRaft]);
9647 strcpy(weapon_string[iwSideLadder],old_weapon_string[iwSideLadder]);
9648 }
9649 */
9650 113 }
9651 else
9652 {
9653
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 16 times.
4112 for(int32_t i=0; i<MAXWPNS; i++)
9654 4096 reset_weaponname(i);
9655 }
9656
9657
2/2
✓ Branch 0 taken 30768 times.
✓ Branch 1 taken 129 times.
30897 for(int32_t i=0; i<weapons_to_read; i++)
9658 {
9659 30768 word oldtile = 0;
9660
2/2
✓ Branch 0 taken 8704 times.
✓ Branch 1 taken 22064 times.
30768 if (s_version < 8)
9661 {
9662
1/2
✓ Branch 0 taken 22064 times.
✗ Branch 1 not taken.
22064 if (!p_igetw(&oldtile, f))
9663 return qe_invalid;
9664 22064 }
9665
9666
1/2
✓ Branch 0 taken 30768 times.
✗ Branch 1 not taken.
30768 if(!p_getc(&tempweapon.misc,f))
9667 {
9668 return qe_invalid;
9669 }
9670
9671
1/2
✓ Branch 0 taken 30768 times.
✗ Branch 1 not taken.
30768 if(!p_getc(&tempweapon.csets,f))
9672 {
9673 return qe_invalid;
9674 }
9675
9676
1/2
✓ Branch 0 taken 30768 times.
✗ Branch 1 not taken.
30768 if(!p_getc(&tempweapon.frames,f))
9677 {
9678 return qe_invalid;
9679 }
9680
9681
1/2
✓ Branch 0 taken 30768 times.
✗ Branch 1 not taken.
30768 if(!p_getc(&tempweapon.speed,f))
9682 {
9683 return qe_invalid;
9684 }
9685
9686
1/2
✓ Branch 0 taken 30768 times.
✗ Branch 1 not taken.
30768 if(!p_getc(&tempweapon.type,f))
9687 {
9688 return qe_invalid;
9689 }
9690
9691
2/2
✓ Branch 0 taken 21552 times.
✓ Branch 1 taken 9216 times.
30768 if ( s_version >= 7 )
9692 {
9693
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetw(&tempweapon.script,f))
9694 {
9695 return qe_invalid;
9696 }
9697
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempweapon.tile,f))
9698 {
9699 return qe_invalid;
9700 }
9701 9216 }
9702
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 21552 times.
30768 if ( s_version < 7 )
9703 {
9704 21552 tempweapon.tile = oldtile;
9705 21552 }
9706
9707
2/2
✓ Branch 0 taken 29744 times.
✓ Branch 1 taken 1024 times.
30768 if(Header->zelda_version < 0x193)
9708 {
9709
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&padding,f))
9710 {
9711 return qe_invalid;
9712 }
9713 1024 }
9714
9715
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 1840 times.
30768 if(s_version < 6)
9716 {
9717
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1836 times.
1840 if(i==ewFIRETRAIL)
9718 {
9719 4 tempweapon.misc |= WF_BEHIND;
9720 4 }
9721 else
9722 1836 tempweapon.misc &= ~WF_BEHIND;
9723 1840 }
9724
9725 30768 memcpy(&wpnsbuf[i], &tempweapon, sizeof(tempweapon));
9726 30768 }
9727
9728
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<2)
9729 {
9730 16 wpnsbuf[wSBOOM]=wpnsbuf[wBOOM];
9731 16 }
9732
9733
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<5)
9734 {
9735 16 wpnsbuf[iwQuarterHearts].tile=1;
9736 16 wpnsbuf[iwQuarterHearts].csets=1;
9737 16 }
9738
9739
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(Header->zelda_version < 0x176)
9740 {
9741 wpnsbuf[iwSpawn] = *((wpndata*)(itemsbuf + iMisc1));
9742 wpnsbuf[iwDeath] = *((wpndata*)(itemsbuf + iMisc2));
9743 memset(&itemsbuf[iMisc1],0,sizeof(itemdata));
9744 memset(&itemsbuf[iMisc2],0,sizeof(itemdata));
9745 }
9746
9747
2/4
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if((Header->zelda_version < 0x192)||
9748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 ((Header->zelda_version == 0x192)&&(Header->build<129)))
9749 {
9750 4 wpnsbuf[wHSCHAIN_V] = wpnsbuf[wHSCHAIN_H];
9751 4 }
9752
9753
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if((Header->zelda_version < 0x210))
9754 {
9755 4 wpnsbuf[wLSHEAD] = wpnsbuf[wHSHEAD];
9756 4 wpnsbuf[wLSCHAIN_H] = wpnsbuf[wHSCHAIN_H];
9757 4 wpnsbuf[wLSHANDLE] = wpnsbuf[wHSHANDLE];
9758 4 wpnsbuf[wLSCHAIN_V] = wpnsbuf[wHSCHAIN_V];
9759 4 }
9760
9761 129 return 0;
9762 129 }
9763
9764 129 void init_guys(int32_t guyversion)
9765 {
9766
2/2
✓ Branch 0 taken 66048 times.
✓ Branch 1 taken 129 times.
66177 for(int32_t i=0; i<MAXGUYS; i++)
9767 {
9768 66048 guysbuf[i] = default_guys[0];
9769 66048 }
9770
9771
2/2
✓ Branch 0 taken 22833 times.
✓ Branch 1 taken 129 times.
22962 for(int32_t i=0; i<OLDMAXGUYS; i++)
9772 {
9773 22833 guysbuf[i] = default_guys[i];
9774
2/2
✓ Branch 0 taken 22575 times.
✓ Branch 1 taken 258 times.
22833 guysbuf[i].spr_shadow = (guysbuf[i].family==eeROCK && guysbuf[i].misc10==1) ? iwLargeShadow : iwShadow;
9775 22833 guysbuf[i].spr_death = iwDeath;
9776 22833 guysbuf[i].spr_spawn = iwSpawn;
9777 // Patra fix: 2.10 BSPatras used spDIG. 2.50 Patras use CSet 7.
9778
4/4
✓ Branch 0 taken 2832 times.
✓ Branch 1 taken 20001 times.
✓ Branch 2 taken 2816 times.
✓ Branch 3 taken 16 times.
22833 if(guyversion<=3 && i==ePATRABS)
9779 {
9780 16 guysbuf[i].bosspal=spDIG;
9781 16 guysbuf[i].cset=14;
9782 16 guysbuf[i].misc9=14;
9783 16 }
9784
9785
2/2
✓ Branch 0 taken 20001 times.
✓ Branch 1 taken 2832 times.
22833 if(guyversion<=3)
9786 {
9787 // Rope/Ghini Flash rules
9788
2/2
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 2124 times.
2832 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
9789 {
9790
2/2
✓ Branch 0 taken 2112 times.
✓ Branch 1 taken 12 times.
2124 if(i==eROPE2)
9791 {
9792 12 guysbuf[i].flags2 &= ~guy_flashing;
9793 12 }
9794 2124 }
9795
9796
2/2
✓ Branch 0 taken 2301 times.
✓ Branch 1 taken 531 times.
2832 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
9797 {
9798
12/12
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 525 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 522 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 519 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 516 times.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 11 taken 513 times.
531 if(i==eBUBBLEST || i==eBUBBLESP || i==eBUBBLESR || i==eBUBBLEIT || i==eBUBBLEIP || i==eBUBBLEIR)
9799 {
9800 18 guysbuf[i].flags2 &= ~guy_flashing;
9801 18 }
9802 531 }
9803
9804
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 16 times.
2832 if(i==eGHINI2)
9805 {
9806
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
16 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
9807 {
9808 3 guysbuf[i].flags2 |= guy_blinking;
9809 3 }
9810
9811
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
9812 {
9813 guysbuf[i].flags2 |= guy_transparent;
9814 }
9815 16 }
9816 2832 }
9817
9818 // Darknut fix
9819
10/10
✓ Branch 0 taken 22704 times.
✓ Branch 1 taken 129 times.
✓ Branch 2 taken 22575 times.
✓ Branch 3 taken 129 times.
✓ Branch 4 taken 22446 times.
✓ Branch 5 taken 129 times.
✓ Branch 6 taken 22317 times.
✓ Branch 7 taken 129 times.
✓ Branch 8 taken 129 times.
✓ Branch 9 taken 22188 times.
22833 if(i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)
9820 {
9821
2/2
✓ Branch 0 taken 435 times.
✓ Branch 1 taken 210 times.
645 if(get_qr(qr_NEWENEMYTILES))
9822 {
9823 435 guysbuf[i].s_tile=guysbuf[i].e_tile+120;
9824 435 guysbuf[i].s_width=guysbuf[i].e_width;
9825 435 guysbuf[i].s_height=guysbuf[i].e_height;
9826 435 }
9827 210 else guysbuf[i].s_tile=860;
9828
9829
2/2
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 80 times.
645 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
9830 {
9831 80 guysbuf[i].flags |= guy_bkshield;
9832 80 }
9833 645 }
9834
9835
4/4
✓ Branch 0 taken 22704 times.
✓ Branch 1 taken 129 times.
✓ Branch 2 taken 22825 times.
✓ Branch 3 taken 8 times.
22833 if((i==eGELTRIB || i==eFGELTRIB) && get_bit(deprecated_rules,qr_OLDTRIBBLES_DEP))
9836 {
9837 8 guysbuf[i].misc3 = (i==eFGELTRIB ? eFZOL : eZOL);
9838 8 }
9839 22833 }
9840 129 }
9841
9842 4096 void reset_weaponname(int32_t i)
9843 {
9844
2/2
✓ Branch 0 taken 1408 times.
✓ Branch 1 taken 2688 times.
4096 if(i<wLast)
9845 {
9846 1408 strcpy(weapon_string[i],old_weapon_string[i]);
9847 1408 }
9848 else
9849 2688 sprintf(weapon_string[i],"zz%03d",i);
9850 4096 }
9851
9852 129 void init_item_drop_sets()
9853 {
9854
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
9855 {
9856 // item_drop_sets[i] = default_item_drop_sets[0];
9857 33024 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
9858 33024 }
9859
9860
2/2
✓ Branch 0 taken 1677 times.
✓ Branch 1 taken 129 times.
1806 for(int32_t i=0; i<isMAX; i++)
9861 {
9862 1677 item_drop_sets[i] = default_item_drop_sets[i];
9863
9864 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
9865
2/2
✓ Branch 0 taken 16770 times.
✓ Branch 1 taken 1677 times.
18447 for(int32_t j=0; j<10; ++j)
9866 {
9867 16770 int32_t it = item_drop_sets[i].item[j];
9868
9869
3/4
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 4994 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 756 times.
16770 if((itemsbuf[it].family == itype_rupee && ((itemsbuf[it].amount)&0xFFF) == 10)
9870
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 11020 times.
11776 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
9871 {
9872 756 item_drop_sets[i].chance[j+1]=0;
9873 756 }
9874
3/4
✓ Branch 0 taken 516 times.
✓ Branch 1 taken 15498 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 516 times.
16014 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
9875 {
9876 item_drop_sets[i].chance[j+1]=0;
9877 }
9878
9879 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
9880
2/2
✓ Branch 0 taken 16762 times.
✓ Branch 1 taken 8 times.
16770 if(itemsbuf[it].family == itype_misc)
9881 {
9882 // If a non-gameplay item was selected, then item drop was aborted.
9883 // Reflect this by increasing the 'Nothing' chance accordingly.
9884 8 item_drop_sets[i].chance[0]+=item_drop_sets[i].chance[j+1];
9885 8 item_drop_sets[i].chance[j+1]=0;
9886 8 }
9887 16770 }
9888 1677 }
9889 129 }
9890
9891 125 void init_favorites()
9892 {
9893
2/2
✓ Branch 0 taken 37500 times.
✓ Branch 1 taken 125 times.
37625 for(int32_t i=0; i<MAXFAVORITECOMBOS; i++)
9894 {
9895 37500 favorite_combos[i]=-1;
9896 37500 }
9897
9898
2/2
✓ Branch 0 taken 37500 times.
✓ Branch 1 taken 125 times.
37625 for(int32_t i=0; i<MAXFAVORITECOMBOALIASES; i++)
9899 {
9900 37500 favorite_comboaliases[i]=-1;
9901 37500 }
9902 125 }
9903
9904 const char *ctype_name[cMAX]=
9905 {
9906 "cNONE", "cSTAIR", "cCAVE", "cWATER", "cARMOS", "cGRAVE", "cDOCK",
9907 "cUNDEF", "cPUSH_WAIT", "cPUSH_HEAVY", "cPUSH_HW", "cL_STATUE", "cR_STATUE",
9908 "cWALKSLOW", "cCVUP", "cCVDOWN", "cCVLEFT", "cCVRIGHT", "cSWIMWARP", "cDIVEWARP",
9909 "cLADDERHOOKSHOT", "cTRIGNOFLAG", "cTRIGFLAG", "cZELDA", "cSLASH", "cSLASHITEM",
9910 "cPUSH_HEAVY2", "cPUSH_HW2", "cPOUND", "cHSGRAB", "cHSBRIDGE", "cDAMAGE1",
9911 "cDAMAGE2", "cDAMAGE3", "cDAMAGE4", "cC_STATUE", "cTRAP_H", "cTRAP_V", "cTRAP_4",
9912 "cTRAP_LR", "cTRAP_UD", "cPIT", "cHOOKSHOTONLY", "cOVERHEAD", "cNOFLYZONE", "cMIRROR",
9913 "cMIRRORSLASH", "cMIRRORBACKSLASH", "cMAGICPRISM", "cMAGICPRISM4",
9914 "cMAGICSPONGE", "cCAVE2", "cEYEBALL_A", "cEYEBALL_B", "cNOJUMPZONE", "cBUSH",
9915 "cFLOWERS", "cTALLGRASS", "cSHALLOWWATER", "cLOCKBLOCK", "cLOCKBLOCK2",
9916 "cBOSSLOCKBLOCK", "cBOSSLOCKBLOCK2", "cLADDERONLY", "cBSGRAVE",
9917 "cCHEST", "cCHEST2", "cLOCKEDCHEST", "cLOCKEDCHEST2", "cBOSSCHEST", "cBOSSCHEST2",
9918 "cRESET", "cSAVE", "cSAVE2", "cCAVEB", "cCAVEC", "cCAVED",
9919 "cSTAIRB", "cSTAIRC", "cSTAIRD", "cPITB", "cPITC", "cPITD",
9920 "cCAVE2B", "cCAVE2C", "cCAVE2D", "cSWIMWARPB", "cSWIMWARPC", "cSWIMWARPD",
9921 "cDIVEWARPB", "cDIVEWARPC", "cDIVEWARPD", "cSTAIRR", "cPITR",
9922 "cAWARPA", "cAWARPB", "cAWARPC", "cAWARPD", "cAWARPR",
9923 "cSWARPA", "cSWARPB", "cSWARPC", "cSWARPD", "cSWARPR", "cSTRIGNOFLAG", "cSTRIGFLAG",
9924 "cSTEP", "cSTEPSAME", "cSTEPALL", "cSTEPCOPY", "cNOENEMY", "cBLOCKARROW1", "cBLOCKARROW2",
9925 "cBLOCKARROW3", "cBLOCKBRANG1", "cBLOCKBRANG2", "cBLOCKBRANG3", "cBLOCKSBEAM", "cBLOCKALL",
9926 "cBLOCKFIREBALL", "cDAMAGE5", "cDAMAGE6", "cDAMAGE7", "cCHANGE", "cSPINTILE1", "cSPINTILE2",
9927 "cSCREENFREEZE", "cSCREENFREEZEFF", "cNOGROUNDENEMY", "cSLASHNEXT", "cSLASHNEXTITEM", "cBUSHNEXT"
9928 "cSLASHTOUCHY", "cSLASHITEMTOUCHY", "cBUSHTOUCHY", "cFLOWERSTOUCHY", "cTALLGRASSTOUCHY",
9929 "cSLASHNEXTTOUCHY", "cSLASHNEXTITEMTOUCHY", "cBUSHNEXTTOUCHY", "cEYEBALL_4", "cTALLGRASSNEXT",
9930 "cSCRIPT1", "cSCRIPT2", "cSCRIPT3", "cSCRIPT4", "cSCRIPT5",
9931 "cSCRIPT6", "cSCRIPT7", "cSCRIPT8", "cSCRIPT9", "cSCRIPT10",
9932 "cSCRIPT11", "cSCRIPT12", "cSCRIPT13", "cSCRIPT14", "cSCRIPT15",
9933 "cSCRIPT16", "cSCRIPT17", "cSCRIPT18", "cSCRIPT19", "cSCRIPT20"
9934
9935 };
9936
9937 224 int32_t init_combo_classes()
9938 {
9939
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 224 times.
224 zinfo* zi = (load_tmp_zi ? load_tmp_zi : &ZI);
9940
2/2
✓ Branch 0 taken 40544 times.
✓ Branch 1 taken 224 times.
40768 for(int32_t i=0; i<cMAX; i++)
9941 {
9942 40544 combo_class_buf[i] = default_combo_classes[i];
9943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40544 times.
40544 if ( char const* nm = zi->getComboTypeName(i) )
9944 {
9945 40544 size_t len = strlen(nm);
9946
2/2
✓ Branch 0 taken 2594816 times.
✓ Branch 1 taken 40544 times.
2635360 for ( size_t q = 0; q < 64; q++ )
9947 {
9948
2/2
✓ Branch 0 taken 599200 times.
✓ Branch 1 taken 1995616 times.
2594816 combo_class_buf[i].name[q] = (q<len ? nm[q] : 0);
9949 2594816 }
9950 40544 }
9951 40544 }
9952
9953 224 return 0;
9954 }
9955
9956 97 int32_t readherosprites2(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites)
9957 {
9958
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 assert(v_herosprites < 6);
9959 //these are here to bypass compiler warnings about unused arguments
9960 97 cv_herosprites=cv_herosprites;
9961
9962 97 zinit.hero_swim_speed=67; //default
9963 97 setupherotiles(zinit.heroAnimationStyle);
9964 97 setupherodefenses();
9965 97 setupherooffsets();
9966
9967
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 77 times.
97 if(v_herosprites>=0)
9968 {
9969 word tile, tile2;
9970 byte flip, extend, dummy_byte;
9971
9972
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
9973 {
9974
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
9975 {
9976 return qe_invalid;
9977 }
9978
9979
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
9980 {
9981 return qe_invalid;
9982 }
9983
9984
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
9985 {
9986 return qe_invalid;
9987 }
9988
9989 308 walkspr[i][spr_tile]=(int32_t)tile;
9990 308 walkspr[i][spr_flip]=(int32_t)flip;
9991 308 walkspr[i][spr_extend]=(int32_t)extend;
9992 308 }
9993
9994
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
9995 {
9996
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
9997 {
9998 return qe_invalid;
9999 }
10000
10001
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10002 {
10003 return qe_invalid;
10004 }
10005
10006
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10007 {
10008 return qe_invalid;
10009 }
10010
10011 308 stabspr[i][spr_tile]=(int32_t)tile;
10012 308 stabspr[i][spr_flip]=(int32_t)flip;
10013 308 stabspr[i][spr_extend]=(int32_t)extend;
10014 308 }
10015
10016
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10017 {
10018
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10019 {
10020 return qe_invalid;
10021 }
10022
10023
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10024 {
10025 return qe_invalid;
10026 }
10027
10028
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10029 {
10030 return qe_invalid;
10031 }
10032
10033 308 slashspr[i][spr_tile]=(int32_t)tile;
10034 308 slashspr[i][spr_flip]=(int32_t)flip;
10035 308 slashspr[i][spr_extend]=(int32_t)extend;
10036 308 }
10037
10038
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10039 {
10040
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10041 {
10042 return qe_invalid;
10043 }
10044
10045
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10046 {
10047 return qe_invalid;
10048 }
10049
10050
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10051 {
10052 return qe_invalid;
10053 }
10054
10055 308 floatspr[i][spr_tile]=(int32_t)tile;
10056 308 floatspr[i][spr_flip]=(int32_t)flip;
10057 308 floatspr[i][spr_extend]=(int32_t)extend;
10058 308 }
10059
10060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>1)
10061 {
10062
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10063 {
10064
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10065 {
10066 return qe_invalid;
10067 }
10068
10069
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10070 {
10071 return qe_invalid;
10072 }
10073
10074
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10075 {
10076 return qe_invalid;
10077 }
10078
10079 308 swimspr[i][spr_tile]=(int32_t)tile;
10080 308 swimspr[i][spr_flip]=(int32_t)flip;
10081 308 swimspr[i][spr_extend]=(int32_t)extend;
10082 308 }
10083 77 }
10084
10085
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10086 {
10087
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10088 {
10089 return qe_invalid;
10090 }
10091
10092
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10093 {
10094 return qe_invalid;
10095 }
10096
10097
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10098 {
10099 return qe_invalid;
10100 }
10101
10102 308 divespr[i][spr_tile]=(int32_t)tile;
10103 308 divespr[i][spr_flip]=(int32_t)flip;
10104 308 divespr[i][spr_extend]=(int32_t)extend;
10105 308 }
10106
10107
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10108 {
10109
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10110 {
10111 return qe_invalid;
10112 }
10113
10114
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10115 {
10116 return qe_invalid;
10117 }
10118
10119
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10120 {
10121 return qe_invalid;
10122 }
10123
10124 308 poundspr[i][spr_tile]=(int32_t)tile;
10125 308 poundspr[i][spr_flip]=(int32_t)flip;
10126 308 poundspr[i][spr_extend]=(int32_t)extend;
10127 308 }
10128
10129
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&tile,f))
10130 {
10131 return qe_invalid;
10132 }
10133
10134 77 flip=0;
10135
10136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>0)
10137 {
10138
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_getc(&flip,f))
10139 {
10140 return qe_invalid;
10141 }
10142 77 }
10143
10144
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_getc(&extend,f))
10145 {
10146 return qe_invalid;
10147 }
10148
10149 77 castingspr[spr_tile]=(int32_t)tile;
10150 77 castingspr[spr_flip]=(int32_t)flip;
10151 77 castingspr[spr_extend]=(int32_t)extend;
10152
10153
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(v_herosprites>0)
10154 {
10155 77 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10156
2/2
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 77 times.
231 for(int32_t i=0; i<2; i++)
10157 {
10158
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 154 times.
462 for(int32_t j=0; j<num_holdsprs; j++)
10159 {
10160
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10161 {
10162 return qe_invalid;
10163 }
10164
10165
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10166 {
10167 return qe_invalid;
10168 }
10169
10170
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10171 {
10172 return qe_invalid;
10173 }
10174
10175 308 holdspr[i][j][spr_tile]=(int32_t)tile;
10176 308 holdspr[i][j][spr_flip]=(int32_t)flip;
10177 308 holdspr[i][j][spr_extend]=(int32_t)extend;
10178 308 }
10179 154 }
10180 77 }
10181 else
10182 {
10183 for(int32_t i=0; i<2; i++)
10184 {
10185 if(!p_igetw(&tile,f))
10186 {
10187 return qe_invalid;
10188 }
10189
10190 if(!p_igetw(&tile2,f))
10191 {
10192 return qe_invalid;
10193 }
10194
10195 if(!p_getc(&extend,f))
10196 {
10197 return qe_invalid;
10198 }
10199
10200 holdspr[i][spr_hold1][spr_tile]=(int32_t)tile;
10201 holdspr[i][spr_hold1][spr_flip]=(int32_t)flip;
10202 holdspr[i][spr_hold1][spr_extend]=(int32_t)extend;
10203 holdspr[i][spr_hold2][spr_tile]=(int32_t)tile2;
10204 holdspr[i][spr_hold2][spr_flip]=(int32_t)flip;
10205 holdspr[i][spr_hold2][spr_extend]=(int32_t)extend;
10206 }
10207 }
10208
10209
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>2)
10210 {
10211
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10212 {
10213
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10214 {
10215 return qe_invalid;
10216 }
10217
10218
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10219 {
10220 return qe_invalid;
10221 }
10222
10223
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10224 {
10225 return qe_invalid;
10226 }
10227
10228 308 jumpspr[i][spr_tile]=(int32_t)tile;
10229 308 jumpspr[i][spr_flip]=(int32_t)flip;
10230 308 jumpspr[i][spr_extend]=(int32_t)extend;
10231 308 }
10232 77 }
10233
10234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>3)
10235 {
10236
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10237 {
10238
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10239 {
10240 return qe_invalid;
10241 }
10242
10243
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10244 {
10245 return qe_invalid;
10246 }
10247
10248
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10249 {
10250 return qe_invalid;
10251 }
10252
10253 308 chargespr[i][spr_tile]=(int32_t)tile;
10254 308 chargespr[i][spr_flip]=(int32_t)flip;
10255 308 chargespr[i][spr_extend]=(int32_t)extend;
10256 308 }
10257 77 }
10258
10259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>4)
10260 {
10261
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_getc(&dummy_byte,f))
10262 {
10263 return qe_invalid;
10264 }
10265
10266 77 zinit.hero_swim_speed=(byte)dummy_byte;
10267 77 }
10268
10269 77 memset(frozenspr, 0, sizeof(frozenspr));
10270 77 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10271 77 memset(onfirespr, 0, sizeof(onfirespr));
10272 77 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10273 77 memset(diggingspr, 0, sizeof(diggingspr));
10274 77 memset(usingrodspr, 0, sizeof(usingrodspr));
10275 77 memset(usingcanespr, 0, sizeof(usingcanespr));
10276 77 memset(pushingspr, 0, sizeof(pushingspr));
10277 77 memset(liftingspr, 0, sizeof(liftingspr));
10278 77 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10279 77 memset(stunnedspr, 0, sizeof(stunnedspr));
10280 77 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10281 77 memset(fallingspr, 0, sizeof(fallingspr));
10282 77 memset(shockedspr, 0, sizeof(shockedspr));
10283 77 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10284 77 memset(pullswordspr, 0, sizeof(pullswordspr));
10285 77 memset(readingspr, 0, sizeof(readingspr));
10286 77 memset(slash180spr, 0, sizeof(slash180spr));
10287 77 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10288 77 memset(dashspr, 0, sizeof(dashspr));
10289 77 memset(bonkspr, 0, sizeof(bonkspr));
10290 77 memset(medallionsprs, 0, sizeof(medallionsprs));
10291 77 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10292 77 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10293
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t q = 0; q < 4; ++q)
10294 {
10295
2/2
✓ Branch 0 taken 924 times.
✓ Branch 1 taken 308 times.
1232 for(int32_t p = 0; p < 3; ++p)
10296 {
10297 924 drowningspr[q][p] = divespr[q][p];
10298 924 drowning_lavaspr[q][p] = divespr[q][p];
10299 924 }
10300 308 }
10301 77 memset(sideswimspr, 0, sizeof(sideswimspr));
10302 77 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
10303 77 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
10304 77 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
10305 77 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
10306 77 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
10307 77 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
10308 77 }
10309
10310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(FFCore.quest_format[vInitData] < 34)
10311 {
10312 97 bool fastswim = zinit.hero_swim_speed > 60;
10313 // '2/3' or '1/2'
10314 97 zinit.hero_swim_mult = fastswim ? 2 : 1;
10315 97 zinit.hero_swim_div = fastswim ? 3 : 2;
10316 97 }
10317 97 return 0;
10318 97 }
10319
10320 6120 void setSprite(int32_t* arr, int32_t tile, int32_t flip, int32_t ext)
10321 {
10322 6120 arr[spr_tile] = tile;
10323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6120 times.
6120 arr[spr_flip] = (flip > 3 ? 0 : flip);
10324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6120 times.
6120 arr[spr_extend] = (ext > 2 ? 0 : ext);
10325 6120 }
10326 //Used to read the player sprites as int32_t, not word.
10327 36 int32_t readherosprites3(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites)
10328 {
10329 //these are here to bypass compiler warnings about unused arguments
10330 36 cv_herosprites=cv_herosprites;
10331
10332 36 zinit.hero_swim_speed=67; //default
10333 36 setupherotiles(zinit.heroAnimationStyle);
10334 36 setupherodefenses();
10335 36 setupherooffsets();
10336
10337 int32_t tile, tile2;
10338 byte flip, extend, dummy_byte;
10339
10340
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(v_herosprites>=0)
10341 {
10342
10343
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t i=0; i<4; i++)
10344 {
10345
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10346 {
10347 return qe_invalid;
10348 }
10349
10350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10351 {
10352 return qe_invalid;
10353 }
10354
10355
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10356 {
10357 return qe_invalid;
10358 }
10359
10360 144 setSprite(walkspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10361 144 }
10362
10363
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t i=0; i<4; i++)
10364 {
10365
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10366 {
10367 return qe_invalid;
10368 }
10369
10370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10371 {
10372 return qe_invalid;
10373 }
10374
10375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10376 {
10377 return qe_invalid;
10378 }
10379
10380 144 setSprite(stabspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10381 144 }
10382
10383
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t i=0; i<4; i++)
10384 {
10385
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10386 {
10387 return qe_invalid;
10388 }
10389
10390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10391 {
10392 return qe_invalid;
10393 }
10394
10395
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10396 {
10397 return qe_invalid;
10398 }
10399
10400 144 setSprite(slashspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10401 144 }
10402
10403
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t i=0; i<4; i++)
10404 {
10405
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10406 {
10407 return qe_invalid;
10408 }
10409
10410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10411 {
10412 return qe_invalid;
10413 }
10414
10415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10416 {
10417 return qe_invalid;
10418 }
10419
10420 144 setSprite(floatspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10421 144 }
10422
10423
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(v_herosprites>1)
10424 {
10425
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t i=0; i<4; i++)
10426 {
10427
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10428 {
10429 return qe_invalid;
10430 }
10431
10432
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10433 {
10434 return qe_invalid;
10435 }
10436
10437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10438 {
10439 return qe_invalid;
10440 }
10441
10442 144 setSprite(swimspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10443 144 }
10444 36 }
10445
10446
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t i=0; i<4; i++)
10447 {
10448
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10449 {
10450 return qe_invalid;
10451 }
10452
10453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10454 {
10455 return qe_invalid;
10456 }
10457
10458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10459 {
10460 return qe_invalid;
10461 }
10462
10463 144 setSprite(divespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10464 144 }
10465
10466
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t i=0; i<4; i++)
10467 {
10468
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10469 {
10470 return qe_invalid;
10471 }
10472
10473
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10474 {
10475 return qe_invalid;
10476 }
10477
10478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10479 {
10480 return qe_invalid;
10481 }
10482
10483 144 setSprite(poundspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10484 144 }
10485
10486
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tile,f))
10487 {
10488 return qe_invalid;
10489 }
10490
10491 36 flip=0;
10492
10493
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(v_herosprites>0)
10494 {
10495
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&flip,f))
10496 {
10497 return qe_invalid;
10498 }
10499 36 }
10500
10501
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&extend,f))
10502 {
10503 return qe_invalid;
10504 }
10505
10506 36 setSprite(castingspr, int32_t(tile), int32_t(flip), int32_t(extend));
10507
10508
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(v_herosprites>0)
10509 {
10510 36 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10511
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 36 times.
108 for(int32_t i=0; i<2; i++)
10512 {
10513
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 72 times.
288 for(int32_t j=0; j<num_holdsprs; j++)
10514 {
10515
1/2
✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
216 if(!p_igetl(&tile,f))
10516 {
10517 return qe_invalid;
10518 }
10519
10520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
216 if(!p_getc(&flip,f))
10521 {
10522 return qe_invalid;
10523 }
10524
10525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
216 if(!p_getc(&extend,f))
10526 {
10527 return qe_invalid;
10528 }
10529
10530 216 setSprite(holdspr[i][j], int32_t(tile), int32_t(flip), int32_t(extend));
10531 216 }
10532 72 }
10533 36 }
10534 else
10535 {
10536 for(int32_t i=0; i<2; i++)
10537 {
10538 if(!p_igetl(&tile,f))
10539 {
10540 return qe_invalid;
10541 }
10542
10543 if(!p_igetl(&tile2,f))
10544 {
10545 return qe_invalid;
10546 }
10547
10548 if(!p_getc(&extend,f))
10549 {
10550 return qe_invalid;
10551 }
10552
10553 setSprite(holdspr[i][spr_hold1], int32_t(tile), int32_t(flip), int32_t(extend));
10554 setSprite(holdspr[i][spr_hold2], int32_t(tile2), int32_t(flip), int32_t(extend));
10555 }
10556 }
10557
10558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(v_herosprites>2)
10559 {
10560
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t i=0; i<4; i++)
10561 {
10562
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10563 {
10564 return qe_invalid;
10565 }
10566
10567
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10568 {
10569 return qe_invalid;
10570 }
10571
10572
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10573 {
10574 return qe_invalid;
10575 }
10576
10577 144 setSprite(jumpspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10578 144 }
10579 36 }
10580
10581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(v_herosprites>3)
10582 {
10583
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t i=0; i<4; i++)
10584 {
10585
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10586 {
10587 return qe_invalid;
10588 }
10589
10590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10591 {
10592 return qe_invalid;
10593 }
10594
10595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10596 {
10597 return qe_invalid;
10598 }
10599
10600 144 setSprite(chargespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10601 144 }
10602 36 }
10603
10604
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(v_herosprites>4)
10605 {
10606
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&dummy_byte,f))
10607 {
10608 return qe_invalid;
10609 }
10610
10611 36 zinit.hero_swim_speed=(byte)dummy_byte;
10612 36 }
10613
10614
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(v_herosprites>6)
10615 {
10616
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10617 {
10618
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10619 return qe_invalid;
10620
10621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10622 return qe_invalid;
10623
10624
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10625 return qe_invalid;
10626
10627 144 setSprite(frozenspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10628 144 }
10629
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10630 {
10631
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10632 return qe_invalid;
10633
10634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10635 return qe_invalid;
10636
10637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10638 return qe_invalid;
10639
10640 144 setSprite(frozen_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10641 144 }
10642
10643
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10644 {
10645
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10646 return qe_invalid;
10647
10648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10649 return qe_invalid;
10650
10651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10652 return qe_invalid;
10653
10654 144 setSprite(onfirespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10655 144 }
10656
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10657 {
10658
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10659 return qe_invalid;
10660
10661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10662 return qe_invalid;
10663
10664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10665 return qe_invalid;
10666
10667 144 setSprite(onfire_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10668 144 }
10669
10670
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10671 {
10672
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10673 return qe_invalid;
10674
10675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10676 return qe_invalid;
10677
10678
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10679 return qe_invalid;
10680
10681 144 setSprite(diggingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10682 144 }
10683
10684
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10685 {
10686
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10687 return qe_invalid;
10688
10689
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10690 return qe_invalid;
10691
10692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10693 return qe_invalid;
10694
10695 144 setSprite(usingrodspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10696 144 }
10697
10698
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10699 {
10700
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10701 return qe_invalid;
10702
10703
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10704 return qe_invalid;
10705
10706
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10707 return qe_invalid;
10708
10709 144 setSprite(usingcanespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10710 144 }
10711
10712
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10713 {
10714
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10715 return qe_invalid;
10716
10717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10718 return qe_invalid;
10719
10720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10721 return qe_invalid;
10722
10723 144 setSprite(pushingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10724 144 }
10725
10726
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10727 {
10728
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10729 return qe_invalid;
10730
10731
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10732 return qe_invalid;
10733
10734
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10735 return qe_invalid;
10736
10737 144 byte frames = 0;
10738
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 136 times.
144 if(v_herosprites > 15)
10739 {
10740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136 times.
136 if(!p_getc(&frames,f))
10741 return qe_invalid;
10742 136 }
10743
10744 144 setSprite(liftingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10745 144 liftingspr[q][spr_frames] = frames;
10746 144 }
10747
10748
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10749 {
10750
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10751 return qe_invalid;
10752
10753
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10754 return qe_invalid;
10755
10756
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10757 return qe_invalid;
10758
10759 144 setSprite(liftingwalkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10760 144 }
10761
10762
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10763 {
10764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_igetl(&tile,f))
10765 return qe_invalid;
10766
10767
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10768 return qe_invalid;
10769
10770
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10771 return qe_invalid;
10772
10773 144 setSprite(stunnedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10774 144 }
10775
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10776 {
10777
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10778 return qe_invalid;
10779
10780
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10781 return qe_invalid;
10782
10783
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10784 return qe_invalid;
10785
10786 144 setSprite(stunned_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10787 144 }
10788
10789
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10790 {
10791
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10792 return qe_invalid;
10793
10794
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10795 return qe_invalid;
10796
10797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10798 return qe_invalid;
10799
10800 144 setSprite(drowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10801 144 }
10802
10803
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10804 {
10805
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10806 return qe_invalid;
10807
10808
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10809 return qe_invalid;
10810
10811
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10812 return qe_invalid;
10813
10814 144 setSprite(drowning_lavaspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10815 144 }
10816
10817
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10818 {
10819
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10820 return qe_invalid;
10821
10822
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10823 return qe_invalid;
10824
10825
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10826 return qe_invalid;
10827
10828 144 setSprite(fallingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10829 144 }
10830
10831
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10832 {
10833
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10834 return qe_invalid;
10835
10836
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10837 return qe_invalid;
10838
10839
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10840 return qe_invalid;
10841
10842 144 setSprite(shockedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10843 144 }
10844
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10845 {
10846
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10847 return qe_invalid;
10848
10849
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10850 return qe_invalid;
10851
10852
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10853 return qe_invalid;
10854
10855 144 setSprite(shocked_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10856 144 }
10857
10858
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10859 {
10860
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10861 return qe_invalid;
10862
10863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10864 return qe_invalid;
10865
10866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10867 return qe_invalid;
10868
10869 144 setSprite(pullswordspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10870 144 }
10871
10872
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10873 {
10874
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10875 return qe_invalid;
10876
10877
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10878 return qe_invalid;
10879
10880
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10881 return qe_invalid;
10882
10883 144 setSprite(readingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10884 144 }
10885
10886
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10887 {
10888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_igetl(&tile,f))
10889 return qe_invalid;
10890
10891
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10892 return qe_invalid;
10893
10894
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10895 return qe_invalid;
10896
10897 144 setSprite(slash180spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10898 144 }
10899
10900
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10901 {
10902
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10903 return qe_invalid;
10904
10905
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10906 return qe_invalid;
10907
10908
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10909 return qe_invalid;
10910
10911 144 setSprite(slashZ4spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10912 144 }
10913
10914
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10915 {
10916
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10917 return qe_invalid;
10918
10919
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10920 return qe_invalid;
10921
10922
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10923 return qe_invalid;
10924
10925 144 setSprite(dashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10926 144 }
10927
10928
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10929 {
10930
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10931 return qe_invalid;
10932
10933
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10934 return qe_invalid;
10935
10936
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10937 return qe_invalid;
10938
10939 144 setSprite(bonkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10940 144 }
10941
10942
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 36 times.
144 for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs
10943 {
10944
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(!p_igetl(&tile,f))
10945 return qe_invalid;
10946
10947
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(!p_getc(&flip,f))
10948 return qe_invalid;
10949
10950
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(!p_getc(&extend,f))
10951 return qe_invalid;
10952
10953 108 setSprite(medallionsprs[q], int32_t(tile), int32_t(flip), int32_t(extend));
10954 108 }
10955 36 }
10956 else
10957 {
10958 memset(frozenspr, 0, sizeof(frozenspr));
10959 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10960 memset(onfirespr, 0, sizeof(onfirespr));
10961 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10962 memset(diggingspr, 0, sizeof(diggingspr));
10963 memset(usingrodspr, 0, sizeof(usingrodspr));
10964 memset(usingcanespr, 0, sizeof(usingcanespr));
10965 memset(pushingspr, 0, sizeof(pushingspr));
10966 memset(liftingspr, 0, sizeof(liftingspr));
10967 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10968 memset(stunnedspr, 0, sizeof(stunnedspr));
10969 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10970 memset(fallingspr, 0, sizeof(fallingspr));
10971 memset(shockedspr, 0, sizeof(shockedspr));
10972 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10973 memset(pullswordspr, 0, sizeof(pullswordspr));
10974 memset(readingspr, 0, sizeof(readingspr));
10975 memset(slash180spr, 0, sizeof(slash180spr));
10976 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10977 memset(dashspr, 0, sizeof(dashspr));
10978 memset(bonkspr, 0, sizeof(bonkspr));
10979 memset(medallionsprs, 0, sizeof(medallionsprs));
10980 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10981 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10982 for(int32_t q = 0; q < 4; ++q)
10983 {
10984 for(int32_t p = 0; p < 3; ++p)
10985 {
10986 drowningspr[q][p] = divespr[q][p];
10987 drowning_lavaspr[q][p] = divespr[q][p];
10988 }
10989 }
10990 }
10991
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (v_herosprites > 8)
10992 {
10993
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10994 {
10995
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10996 return qe_invalid;
10997
10998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10999 return qe_invalid;
11000
11001
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
11002 return qe_invalid;
11003
11004 144 setSprite(sideswimspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11005 144 }
11006 36 }
11007 else
11008 {
11009 memset(sideswimspr, 0, sizeof(sideswimspr));
11010 }
11011
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (v_herosprites > 9)
11012 {
11013
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
11014 {
11015
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
11016 return qe_invalid;
11017
11018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
11019 return qe_invalid;
11020
11021
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
11022 return qe_invalid;
11023
11024 144 setSprite(sideswimslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11025 144 }
11026
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
11027 {
11028
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
11029 return qe_invalid;
11030
11031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
11032 return qe_invalid;
11033
11034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
11035 return qe_invalid;
11036
11037 144 setSprite(sideswimstabspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11038 144 }
11039
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
11040 {
11041
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
11042 return qe_invalid;
11043
11044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
11045 return qe_invalid;
11046
11047
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
11048 return qe_invalid;
11049
11050 144 setSprite(sideswimpoundspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11051 144 }
11052
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
11053 {
11054
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
11055 return qe_invalid;
11056
11057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
11058 return qe_invalid;
11059
11060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
11061 return qe_invalid;
11062
11063 144 setSprite(sideswimchargespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11064 144 }
11065 36 }
11066 else
11067 {
11068 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
11069 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
11070 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
11071 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
11072 }
11073
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (v_herosprites > 10)
11074 {
11075
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
11076 {
11077 int32_t hmr;
11078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_igetl(&hmr,f))
11079 return qe_invalid;
11080
11081 144 hammeroffsets[q] = hmr;
11082 144 }
11083 36 }
11084 else
11085 {
11086 for(int32_t q = 0; q < 4; ++q) hammeroffsets[q] = 0;
11087 }
11088
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (v_herosprites > 11)
11089 {
11090
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 36 times.
144 for(int32_t q = 0; q < 3; ++q)
11091 {
11092
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(!p_igetl(&tile,f))
11093 return qe_invalid;
11094
11095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(!p_getc(&flip,f))
11096 return qe_invalid;
11097
11098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(!p_getc(&extend,f))
11099 return qe_invalid;
11100
11101 108 setSprite(sideswimholdspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11102 108 }
11103 36 }
11104 else
11105 {
11106 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
11107 }
11108
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (v_herosprites > 12)
11109 {
11110
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tile,f))
11111 return qe_invalid;
11112
11113
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&flip,f))
11114 return qe_invalid;
11115
11116
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&extend,f))
11117 return qe_invalid;
11118 36 setSprite(sideswimcastingspr, int32_t(tile), int32_t(flip), int32_t(extend));
11119
11120 36 }
11121 else
11122 {
11123 memset(sideswimcastingspr, 0, sizeof(sideswimcastingspr));
11124 }
11125
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (v_herosprites > 13)
11126 {
11127
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
11128 {
11129
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
11130 return qe_invalid;
11131
11132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
11133 return qe_invalid;
11134
11135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
11136 return qe_invalid;
11137
11138 144 setSprite(sidedrowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11139 144 }
11140 36 }
11141 else
11142 {
11143 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
11144 }
11145
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (v_herosprites > 14)
11146 {
11147
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
11148 {
11149
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
11150 return qe_invalid;
11151
11152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
11153 return qe_invalid;
11154
11155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
11156 return qe_invalid;
11157
11158 144 setSprite(revslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11159 144 }
11160 36 }
11161 else
11162 {
11163 memset(revslashspr, 0, sizeof(revslashspr));
11164 }
11165
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (v_herosprites > 7)
11166 {
11167 36 int32_t num_defense = wMax;
11168 36 byte def = 0;
11169
11170 //Set num_defense accordingly if changes to enum require version upgrade - Jman
11171 /*if(v_herosprites > [x])
11172 * {
11173 * num_defense = 146 //value of wMax on version 8
11174 * }
11175 */
11176
11177
2/2
✓ Branch 0 taken 5256 times.
✓ Branch 1 taken 36 times.
5292 for (int32_t q = 0; q < num_defense; q++)
11178 {
11179
1/2
✓ Branch 0 taken 5256 times.
✗ Branch 1 not taken.
5256 if (!p_getc(&def, f))
11180 return qe_invalid;
11181
11182 5256 hero_defence[q] = def;
11183 5256 }
11184 36 }
11185 else
11186 {
11187 int32_t num_defense = wMax;
11188 for (int32_t q = 0; q < num_defense; q++)
11189 {
11190 hero_defence[q] = 0;
11191 }
11192 }
11193 36 }
11194
11195
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 5 times.
36 if(FFCore.quest_format[vInitData] < 34)
11196 {
11197 5 bool fastswim = zinit.hero_swim_speed > 60;
11198 // '2/3' or '1/2'
11199 5 zinit.hero_swim_mult = fastswim ? 2 : 1;
11200 5 zinit.hero_swim_div = fastswim ? 3 : 2;
11201 5 }
11202 36 return 0;
11203 36 }
11204
11205
11206 113 int32_t readherosprites(PACKFILE *f, zquestheader *Header)
11207 {
11208 //these are here to bypass compiler warnings about unused arguments
11209 113 Header=Header;
11210
11211 dword dummy;
11212 113 word s_version=0, s_cversion=0;
11213
11214 //section version info
11215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(!p_igetw(&s_version,f))
11216 {
11217 return qe_invalid;
11218 }
11219
11220 113 FFCore.quest_format[vHeroSprites] = s_version;
11221
11222 //al_trace("Player sprites version %d\n", s_version);
11223
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&s_cversion,f))
11224 {
11225 return qe_invalid;
11226 }
11227
11228 //section size
11229
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetl(&dummy,f))
11230 {
11231 return qe_invalid;
11232 }
11233
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 77 times.
113 if ( s_version >= 6 )
11234 {
11235 //al_trace("Reading Player Sprites v6\n");
11236 36 return readherosprites3(f, s_version, dummy);
11237 }
11238 77 else return readherosprites2(f, s_version, dummy);
11239 113 }
11240
11241 113 int32_t readsubscreens(PACKFILE *f, zquestheader *Header)
11242 {
11243 int32_t dummy;
11244 113 word s_version=0, s_cversion=0;
11245
11246 //section version info
11247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(!p_igetw(&s_version,f))
11248 {
11249 return qe_invalid;
11250 }
11251
11252 113 FFCore.quest_format[vSubscreen] = s_version;
11253
11254 //al_trace("Subscreens version %d\n", s_version);
11255
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&s_cversion,f))
11256 {
11257 return qe_invalid;
11258 }
11259
11260 //section size
11261
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetl(&dummy,f))
11262 {
11263 return qe_invalid;
11264 }
11265
11266 //finally... section data
11267
2/2
✓ Branch 0 taken 14464 times.
✓ Branch 1 taken 113 times.
14577 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; i++)
11268 {
11269 14464 int32_t ret = read_one_subscreen(f, Header, i, s_version, s_cversion);
11270
11271
1/2
✓ Branch 0 taken 14464 times.
✗ Branch 1 not taken.
14464 if(ret!=0) return ret;
11272 14464 }
11273
11274 113 return 0;
11275 113 }
11276
11277 14464 int32_t read_one_subscreen(PACKFILE *f, zquestheader *, int32_t i, word s_version, word)
11278 {
11279 14464 int32_t numsub=0;
11280 14464 byte temp_ss=0;
11281 subscreen_object temp_sub_stack;
11282 14464 subscreen_object *temp_sub = &temp_sub_stack;
11283
11284 char tempname[64];
11285
11286 // FWIW I never saw anything bigger than 20.
11287 #define MAX_DP1_LEN 1024
11288 char tempdp1[MAX_DP1_LEN];
11289
11290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14464 times.
14464 if(!pfread(tempname,64,f))
11291 {
11292 return qe_invalid;
11293 }
11294
11295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14464 times.
14464 if(s_version > 1)
11296 {
11297
1/2
✓ Branch 0 taken 14464 times.
✗ Branch 1 not taken.
14464 if(!p_getc(&temp_ss,f))
11298 {
11299 return qe_invalid;
11300 }
11301 14464 }
11302
11303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14464 times.
14464 if(s_version < 4)
11304 {
11305 uint8_t tmp=0;
11306
11307 if(!p_getc(&tmp,f))
11308 {
11309 return qe_invalid;
11310 }
11311
11312 numsub = (int32_t)tmp;
11313 }
11314 else
11315 {
11316 word tmp;
11317
11318
1/2
✓ Branch 0 taken 14464 times.
✗ Branch 1 not taken.
14464 if(!p_igetw(&tmp, f))
11319 {
11320 return qe_invalid;
11321 }
11322
11323 14464 numsub = (int32_t)tmp;
11324 }
11325
11326 int32_t j;
11327
11328
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 42368 times.
✓ Branch 2 taken 27904 times.
✓ Branch 3 taken 14464 times.
42368 for(j=0; (j<MAXSUBSCREENITEMS&&j<numsub); j++)
11329 {
11330 27904 memset(temp_sub,0,sizeof(subscreen_object));
11331
11332
2/2
✓ Branch 0 taken 1214 times.
✓ Branch 1 taken 26690 times.
27904 switch(custom_subscreen[i].objects[j].type)
11333 {
11334 case ssoTEXT:
11335 case ssoTEXTBOX:
11336 case ssoCURRENTITEMTEXT:
11337 case ssoCURRENTITEMCLASSTEXT:
11338
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1214 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1214 times.
1214 if(custom_subscreen[i].objects[j].dp1 != NULL) delete [](char *)custom_subscreen[i].objects[j].dp1;
11339
11340 //fall through
11341 default:
11342 27904 memset(&custom_subscreen[i].objects[j],0,sizeof(subscreen_object));
11343 27904 break;
11344 }
11345
11346
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_getc(&(temp_sub->type),f))
11347 {
11348 return qe_invalid;
11349 }
11350
11351
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_getc(&(temp_sub->pos),f))
11352 {
11353 return qe_invalid;
11354 }
11355
11356
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(s_version < 5)
11357 {
11358 switch(temp_sub->pos)
11359 {
11360 case 0:
11361 temp_sub->pos = sspUP | sspDOWN | sspSCROLLING;
11362 break;
11363
11364 case 1:
11365 temp_sub->pos = sspUP;
11366 break;
11367
11368 case 2:
11369 temp_sub->pos = sspDOWN;
11370 break;
11371
11372 default:
11373 temp_sub->pos = 0;
11374 }
11375 }
11376
11377
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetw(&(temp_sub->x),f))
11378 {
11379 return qe_invalid;
11380 }
11381
11382
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetw(&(temp_sub->y),f))
11383 {
11384 return qe_invalid;
11385 }
11386
11387
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetw(&(temp_sub->w),f))
11388 {
11389 return qe_invalid;
11390 }
11391
11392
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetw(&(temp_sub->h),f))
11393 {
11394 return qe_invalid;
11395 }
11396
11397
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_getc(&(temp_sub->colortype1),f))
11398 {
11399 return qe_invalid;
11400 }
11401
11402
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetw(&(temp_sub->color1),f))
11403 {
11404 return qe_invalid;
11405 }
11406
11407
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_getc(&(temp_sub->colortype2),f))
11408 {
11409 return qe_invalid;
11410 }
11411
11412
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetw(&(temp_sub->color2),f))
11413 {
11414 return qe_invalid;
11415 }
11416
11417
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_getc(&(temp_sub->colortype3),f))
11418 {
11419 return qe_invalid;
11420 }
11421
11422
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetw(&(temp_sub->color3),f))
11423 {
11424 return qe_invalid;
11425 }
11426
11427
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetd(&(temp_sub->d1),f))
11428 {
11429 return qe_invalid;
11430 }
11431
11432
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetd(&(temp_sub->d2),f))
11433 {
11434 return qe_invalid;
11435 }
11436
11437
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetd(&(temp_sub->d3),f))
11438 {
11439 return qe_invalid;
11440 }
11441
11442
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetd(&(temp_sub->d4),f))
11443 {
11444 return qe_invalid;
11445 }
11446
11447
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetd(&(temp_sub->d5),f))
11448 {
11449 return qe_invalid;
11450 }
11451
11452
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetd(&(temp_sub->d6),f))
11453 {
11454 return qe_invalid;
11455 }
11456
11457
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetd(&(temp_sub->d7),f))
11458 {
11459 return qe_invalid;
11460 }
11461
11462
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetd(&(temp_sub->d8),f))
11463 {
11464 return qe_invalid;
11465 }
11466
11467
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetd(&(temp_sub->d9),f))
11468 {
11469 return qe_invalid;
11470 }
11471
11472
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetd(&(temp_sub->d10),f))
11473 {
11474 return qe_invalid;
11475 }
11476
11477
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27904 times.
27904 if(s_version < 2)
11478 {
11479 if(!p_igetl(&(temp_sub->speed),f))
11480 {
11481 return qe_invalid;
11482 }
11483
11484 if(!p_igetl(&(temp_sub->delay),f))
11485 {
11486 return qe_invalid;
11487 }
11488
11489 if(!p_igetl(&(temp_sub->frame),f))
11490 {
11491 return qe_invalid;
11492 }
11493 }
11494 else
11495 {
11496
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_getc(&(temp_sub->speed),f))
11497 {
11498 return qe_invalid;
11499 }
11500
11501
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_getc(&(temp_sub->delay),f))
11502 {
11503 return qe_invalid;
11504 }
11505
11506
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetw(&(temp_sub->frame),f))
11507 {
11508 return qe_invalid;
11509 }
11510 }
11511
11512 27904 int32_t temp_size=0;
11513
11514 // bool deletets = false;
11515
4/4
✓ Branch 0 taken 11658 times.
✓ Branch 1 taken 1977 times.
✓ Branch 2 taken 14118 times.
✓ Branch 3 taken 151 times.
27904 switch(temp_sub->type)
11516 {
11517 case ssoTEXT:
11518 case ssoTEXTBOX:
11519 case ssoCURRENTITEMTEXT:
11520 case ssoCURRENTITEMCLASSTEXT:
11521 {
11522 word temptempsize;
11523
11524
1/2
✓ Branch 0 taken 1977 times.
✗ Branch 1 not taken.
1977 if(!p_igetw(&temptempsize,f))
11525 {
11526 return qe_invalid;
11527 }
11528
11529 //temptempsize = temp1 + (temp2 << 8);
11530 1977 temp_size = (int32_t)temptempsize;
11531
11532
11533 1977 uint32_t char_length = temp_size+2;
11534
1/2
✓ Branch 0 taken 1977 times.
✗ Branch 1 not taken.
1977 if (char_length > MAX_DP1_LEN)
11535 {
11536 return qe_invalid;
11537 }
11538 1977 tempdp1[char_length - 1] = '\0';
11539
11540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1977 times.
1977 if(temp_size)
11541 {
11542
1/2
✓ Branch 0 taken 1977 times.
✗ Branch 1 not taken.
1977 if(!pfread(tempdp1,temp_size+1,f))
11543 {
11544 return qe_invalid;
11545 }
11546 1977 }
11547 }
11548 1977 break;
11549
11550 case ssoLIFEMETER:
11551
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(get_bit(deprecated_rules, 12) != 0) // qr_24HC
11552 temp_sub->d3 = 1;
11553
11554
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_getc(&(temp_sub->dp1),f))
11555 {
11556 return qe_invalid;
11557 }
11558
11559 151 break;
11560
11561
11562 case ssoCURRENTITEM:
11563
11564
1/2
✓ Branch 0 taken 11658 times.
✗ Branch 1 not taken.
11658 if(s_version < 6)
11565 {
11566 switch(temp_sub->d1)
11567 {
11568 case ssiBOMB:
11569 temp_sub->d1 = itype_bomb;
11570 break;
11571
11572 case ssiSWORD:
11573 temp_sub->d1 = itype_sword;
11574 break;
11575
11576 case ssiSHIELD:
11577 temp_sub->d1 = itype_shield;
11578 break;
11579
11580 case ssiCANDLE:
11581 temp_sub->d1 = itype_candle;
11582 break;
11583
11584 case ssiLETTER:
11585 temp_sub->d1 = itype_letter;
11586 break;
11587
11588 case ssiPOTION:
11589 temp_sub->d1 = itype_potion;
11590 break;
11591
11592 case ssiLETTERPOTION:
11593 temp_sub->d1 = itype_letterpotion;
11594 break;
11595
11596 case ssiBOW:
11597 temp_sub->d1 = itype_bow;
11598 break;
11599
11600 case ssiARROW:
11601 temp_sub->d1 = itype_arrow;
11602 break;
11603
11604 case ssiBOWANDARROW:
11605 temp_sub->d1 = itype_bowandarrow;
11606 break;
11607
11608 case ssiBAIT:
11609 temp_sub->d1 = itype_bait;
11610 break;
11611
11612 case ssiRING:
11613 temp_sub->d1 = itype_ring;
11614 break;
11615
11616 case ssiBRACELET:
11617 temp_sub->d1 = itype_bracelet;
11618 break;
11619
11620 case ssiMAP:
11621 temp_sub->d1 = itype_map;
11622 break;
11623
11624 case ssiCOMPASS:
11625 temp_sub->d1 = itype_compass;
11626 break;
11627
11628 case ssiBOSSKEY:
11629 temp_sub->d1 = itype_bosskey;
11630 break;
11631
11632 case ssiMAGICKEY:
11633 temp_sub->d1 = itype_magickey;
11634 break;
11635
11636 case ssiBRANG:
11637 temp_sub->d1 = itype_brang;
11638 break;
11639
11640 case ssiWAND:
11641 temp_sub->d1 = itype_wand;
11642 break;
11643
11644 case ssiRAFT:
11645 temp_sub->d1 = itype_raft;
11646 break;
11647
11648 case ssiLADDER:
11649 temp_sub->d1 = itype_ladder;
11650 break;
11651
11652 case ssiWHISTLE:
11653 temp_sub->d1 = itype_whistle;
11654 break;
11655
11656 case ssiBOOK:
11657 temp_sub->d1 = itype_book;
11658 break;
11659
11660 case ssiWALLET:
11661 temp_sub->d1 = itype_wallet;
11662 break;
11663
11664 case ssiSBOMB:
11665 temp_sub->d1 = itype_sbomb;
11666 break;
11667
11668 case ssiHCPIECE:
11669 temp_sub->d1 = itype_heartpiece;
11670 break;
11671
11672 case ssiAMULET:
11673 temp_sub->d1 = itype_amulet;
11674 break;
11675
11676 case ssiFLIPPERS:
11677 temp_sub->d1 = itype_flippers;
11678 break;
11679
11680 case ssiHOOKSHOT:
11681 temp_sub->d1 = itype_hookshot;
11682 break;
11683
11684 case ssiLENS:
11685 temp_sub->d1 = itype_lens;
11686 break;
11687
11688 case ssiHAMMER:
11689 temp_sub->d1 = itype_hammer;
11690 break;
11691
11692 case ssiBOOTS:
11693 temp_sub->d1 = itype_boots;
11694 break;
11695
11696 case ssiDIVINEFIRE:
11697 temp_sub->d1 = itype_divinefire;
11698 break;
11699
11700 case ssiDIVINEESCAPE:
11701 temp_sub->d1 = itype_divineescape;
11702 break;
11703
11704 case ssiDIVINEPROTECTION:
11705 temp_sub->d1 = itype_divineprotection;
11706 break;
11707
11708 case ssiQUIVER:
11709 temp_sub->d1 = itype_quiver;
11710 break;
11711
11712 case ssiBOMBBAG:
11713 temp_sub->d1 = itype_bombbag;
11714 break;
11715
11716 case ssiCBYRNA:
11717 temp_sub->d1 = itype_cbyrna;
11718 break;
11719
11720 case ssiROCS:
11721 temp_sub->d1 = itype_rocs;
11722 break;
11723
11724 case ssiHOVERBOOTS:
11725 temp_sub->d1 = itype_hoverboots;
11726 break;
11727
11728 case ssiSPINSCROLL:
11729 temp_sub->d1 = itype_spinscroll;
11730 break;
11731
11732 case ssiCROSSSCROLL:
11733 temp_sub->d1 = itype_crossscroll;
11734 break;
11735
11736 case ssiQUAKESCROLL:
11737 temp_sub->d1 = itype_quakescroll;
11738 break;
11739
11740 case ssiWHISPRING:
11741 temp_sub->d1 = itype_whispring;
11742 break;
11743
11744 case ssiCHARGERING:
11745 temp_sub->d1 = itype_chargering;
11746 break;
11747
11748 case ssiPERILSCROLL:
11749 temp_sub->d1 = itype_perilscroll;
11750 break;
11751
11752 case ssiWEALTHMEDAL:
11753 temp_sub->d1 = itype_wealthmedal;
11754 break;
11755
11756 case ssiHEARTRING:
11757 temp_sub->d1 = itype_heartring;
11758 break;
11759
11760 case ssiMAGICRING:
11761 temp_sub->d1 = itype_magicring;
11762 break;
11763
11764 case ssiSPINSCROLL2:
11765 temp_sub->d1 = itype_spinscroll2;
11766 break;
11767
11768 case ssiQUAKESCROLL2:
11769 temp_sub->d1 = itype_quakescroll2;
11770 break;
11771
11772 case ssiAGONY:
11773 temp_sub->d1 = itype_agony;
11774 break;
11775
11776 case ssiSTOMPBOOTS:
11777 temp_sub->d1 = itype_stompboots;
11778 break;
11779
11780 case ssiWHIMSICALRING:
11781 temp_sub->d1 = itype_whimsicalring;
11782 break;
11783
11784 case ssiPERILRING:
11785 temp_sub->d1 = itype_perilring;
11786 break;
11787
11788 default:
11789 temp_sub->d1 += itype_custom1 - ssiMAX;
11790 }
11791 }
11792
11793 //fall-through
11794 default:
11795
1/2
✓ Branch 0 taken 25776 times.
✗ Branch 1 not taken.
25776 if(!p_getc(&(temp_sub->dp1),f))
11796 {
11797 return qe_invalid;
11798 }
11799
11800 25776 break;
11801 }
11802
11803
2/2
✓ Branch 0 taken 19220 times.
✓ Branch 1 taken 8684 times.
27904 if(s_version < 7)
11804 {
11805
3/3
✓ Branch 0 taken 8025 times.
✓ Branch 1 taken 227 times.
✓ Branch 2 taken 432 times.
8684 switch(temp_sub->type)
11806 {
11807 case ssoMAGICGAUGE:
11808 {
11809
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 192 times.
227 if(!temp_sub->d9)
11810 192 temp_sub->d9 = -1; //-1 now represents 'always'
11811 227 break;
11812 }
11813 case ssoLIFEGAUGE:
11814 432 temp_sub->d9 = 0; //Unused, doesn't do anything? Clear it...
11815 432 break;
11816 }
11817 8684 }
11818
11819
3/3
✓ Branch 0 taken 1977 times.
✓ Branch 1 taken 24660 times.
✓ Branch 2 taken 1267 times.
27904 switch(temp_sub->type)
11820 {
11821 case ssoTEXT:
11822 case ssoTEXTBOX:
11823 case ssoCURRENTITEMTEXT:
11824 case ssoCURRENTITEMCLASSTEXT:
11825
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1977 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1977 if(custom_subscreen[i].objects[j].dp1 != NULL) delete[](char *)custom_subscreen[i].objects[j].dp1;
11826
11827 1977 memcpy(&custom_subscreen[i].objects[j],temp_sub,sizeof(subscreen_object));
11828 1977 custom_subscreen[i].objects[j].dp1 = NULL;
11829 1977 custom_subscreen[i].objects[j].dp1 = new char[temp_size+2];
11830 1977 strcpy((char*)custom_subscreen[i].objects[j].dp1,tempdp1);
11831 1977 break;
11832
11833 case ssoCOUNTER:
11834
1/2
✓ Branch 0 taken 1267 times.
✗ Branch 1 not taken.
1267 if(s_version<3)
11835 {
11836 temp_sub->d6=(temp_sub->d6?1:0)+(temp_sub->d8?2:0);
11837 temp_sub->d8=0;
11838 }
11839
11840 default:
11841 25927 memcpy(&custom_subscreen[i].objects[j],temp_sub,sizeof(subscreen_object));
11842 25927 break;
11843 }
11844
11845 27904 custom_subscreen[i].name[0] = '\0';
11846 27904 strncat(custom_subscreen[i].name, tempname, 64 - 1);
11847 27904 custom_subscreen[i].ss_type = temp_ss;
11848 27904 }
11849
11850
2/2
✓ Branch 0 taken 3674880 times.
✓ Branch 1 taken 14464 times.
3689344 for(j=numsub; j<MAXSUBSCREENITEMS; j++)
11851 {
11852 //clear all unused object in this subscreen -DD
11853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3674880 times.
3674880 switch(custom_subscreen[i].objects[j].type)
11854 {
11855 case ssoTEXT:
11856 case ssoTEXTBOX:
11857 case ssoCURRENTITEMTEXT:
11858 case ssoCURRENTITEMCLASSTEXT:
11859 if(custom_subscreen[i].objects[j].dp1 != NULL) delete [](char *)custom_subscreen[i].objects[j].dp1;
11860
11861 //fall through
11862 default:
11863 3674880 memset(&custom_subscreen[i].objects[j],0,sizeof(subscreen_object));
11864 3674880 break;
11865 }
11866 3674880 }
11867
11868 14464 return 0;
11869 14464 }
11870
11871 3968 void reset_subscreen(subscreen_group *tempss)
11872 {
11873
2/2
✓ Branch 0 taken 1015808 times.
✓ Branch 1 taken 3968 times.
1019776 for(int32_t i=0; i<MAXSUBSCREENITEMS; ++i)
11874 {
11875
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 1015603 times.
1015808 switch(tempss->objects[i].type)
11876 {
11877 case ssoTEXT:
11878 case ssoTEXTBOX:
11879 case ssoCURRENTITEMTEXT:
11880 case ssoCURRENTITEMCLASSTEXT:
11881
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
✓ Branch 2 taken 205 times.
✗ Branch 3 not taken.
205 if(tempss->objects[i].dp1 != NULL) delete [](char *)tempss->objects[i].dp1;
11882
11883 //fall through
11884 default:
11885 1015808 memset(&tempss->objects[i],0,sizeof(subscreen_object));
11886 1015808 break;
11887 }
11888 1015808 }
11889 3968 }
11890
11891 31 void reset_subscreens()
11892 {
11893
2/2
✓ Branch 0 taken 3968 times.
✓ Branch 1 taken 31 times.
3999 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; ++i)
11894 {
11895 3968 reset_subscreen(&custom_subscreen[i]);
11896 3968 }
11897 31 }
11898
11899 31 int32_t setupsubscreens()
11900 {
11901 31 reset_subscreens();
11902 31 int32_t tempsubscreen=zinit.subscreen;
11903 subscreen_object *tempsub;
11904
11905
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(tempsubscreen>=ssdtMAX)
11906 {
11907 tempsubscreen=0;
11908 }
11909
11910
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
31 switch(tempsubscreen)
11911 {
11912 case ssdtOLD:
11913 case ssdtNEWSUBSCR:
11914 case ssdtREV2:
11915 case ssdtBSZELDA:
11916 case ssdtBSZELDAMODIFIED:
11917 case ssdtBSZELDAENHANCED:
11918 case ssdtBSZELDACOMPLETE:
11919 {
11920 31 tempsub = default_subscreen_active[tempsubscreen][0];
11921 int32_t i;
11922
11923
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2046 times.
✓ Branch 2 taken 2015 times.
✓ Branch 3 taken 31 times.
2046 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
11924 {
11925
2/3
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 1933 times.
✗ Branch 2 not taken.
2015 switch(tempsub[i].type)
11926 {
11927 case ssoTEXT:
11928 case ssoTEXTBOX:
11929 case ssoCURRENTITEMTEXT:
11930 case ssoCURRENTITEMCLASSTEXT:
11931
1/4
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
82 if(custom_subscreen[0].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[0].objects[i].dp1;
11932
11933 82 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
11934 82 custom_subscreen[0].objects[i].dp1 = NULL;
11935 82 custom_subscreen[0].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
11936 82 strcpy((char*)custom_subscreen[0].objects[i].dp1,(char*)tempsub[i].dp1);
11937 82 break;
11938
11939 case ssoLIFEMETER:
11940 {
11941 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
11942
11943 if(get_bit(deprecated_rules, 12) != 0)
11944 custom_subscreen[0].objects[i].d3=1;
11945 else
11946 custom_subscreen[0].objects[i].d3=0;
11947
11948 break;
11949 }
11950 /*
11951 case ssoTRIFRAME:
11952 {
11953 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
11954 custom_subscreen[0].objects[i].d1 = 8594;
11955 custom_subscreen[0].objects[i].d2 = 8;
11956 custom_subscreen[0].objects[i].d3 = 8771;
11957 custom_subscreen[0].objects[i].d4 = 8;
11958 custom_subscreen[0].objects[i].d5 = 1;
11959 custom_subscreen[0].objects[i].d6 = 1;
11960 break;
11961 }*/
11962
11963 default:
11964 1933 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
11965 1933 break;
11966 }
11967 2015 }
11968
11969 31 custom_subscreen[0].ss_type=sstACTIVE;
11970 31 sprintf(custom_subscreen[0].name, "Active Subscreen (Triforce)");
11971 31 tempsub = default_subscreen_active[tempsubscreen][1];
11972
11973
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2046 times.
✓ Branch 2 taken 2015 times.
✓ Branch 3 taken 31 times.
2046 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
11974 {
11975
2/3
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 1920 times.
✗ Branch 2 not taken.
2015 switch(tempsub[i].type)
11976 {
11977 case ssoTEXT:
11978 case ssoTEXTBOX:
11979 case ssoCURRENTITEMTEXT:
11980 case ssoCURRENTITEMCLASSTEXT:
11981
1/4
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
95 if(custom_subscreen[1].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[1].objects[i].dp1;
11982
11983 95 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
11984 95 custom_subscreen[1].objects[i].dp1 = NULL;
11985 95 custom_subscreen[1].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
11986 95 strcpy((char*)custom_subscreen[1].objects[i].dp1,(char*)tempsub[i].dp1);
11987 95 break;
11988
11989 case ssoLIFEMETER:
11990 {
11991 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
11992
11993 if(get_bit(deprecated_rules, 12) != 0)
11994 custom_subscreen[1].objects[i].d3=1;
11995 else
11996 custom_subscreen[1].objects[i].d3=0;
11997
11998 break;
11999 }
12000 /*
12001 case ssoTRIFRAME:
12002 {
12003 custom_subscreen[1].objects[i].d1 = 8594;
12004 custom_subscreen[1].objects[i].d2 = 8;
12005 custom_subscreen[1].objects[i].d3 = 8771;
12006 custom_subscreen[1].objects[i].d4 = 8;
12007 custom_subscreen[1].objects[i].d5 = 1;
12008 custom_subscreen[1].objects[i].d6 = 1;
12009 break;
12010 }*/
12011
12012 default:
12013 1920 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12014 1920 break;
12015 }
12016 2015 }
12017
12018 31 custom_subscreen[1].ss_type=sstACTIVE;
12019 31 sprintf(custom_subscreen[1].name, "Active Subscreen (Dungeon Map)");
12020 // memset(&custom_subscreen[1].objects[i],0,sizeof(subscreen_object));
12021 31 tempsub = default_subscreen_passive[tempsubscreen][0];
12022
12023
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 651 times.
✓ Branch 2 taken 620 times.
✓ Branch 3 taken 31 times.
651 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12024 {
12025
3/3
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 496 times.
✓ Branch 2 taken 31 times.
620 switch(tempsub[i].type)
12026 {
12027 case ssoTEXT:
12028 case ssoTEXTBOX:
12029 case ssoCURRENTITEMTEXT:
12030 case ssoCURRENTITEMCLASSTEXT:
12031
1/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
93 if(custom_subscreen[2].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[2].objects[i].dp1;
12032
12033 93 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12034 93 custom_subscreen[2].objects[i].dp1 = NULL;
12035 93 custom_subscreen[2].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12036 93 strcpy((char*)custom_subscreen[2].objects[i].dp1,(char*)tempsub[i].dp1);
12037 93 break;
12038
12039 case ssoLIFEMETER:
12040 {
12041 31 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12042
12043
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 17 times.
31 if(get_bit(deprecated_rules, 12) != 0)
12044 14 custom_subscreen[2].objects[i].d3=1;
12045 else
12046 17 custom_subscreen[2].objects[i].d3=0;
12047
12048 31 break;
12049 }
12050
12051 default:
12052 496 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12053 496 break;
12054 }
12055 620 }
12056
12057 31 custom_subscreen[2].ss_type=sstPASSIVE;
12058 31 sprintf(custom_subscreen[2].name, "Passive Subscreen (Magic)");
12059 // memset(&custom_subscreen[2].objects[i],0,sizeof(subscreen_object));
12060 31 tempsub = default_subscreen_passive[tempsubscreen][1];
12061
12062
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 620 times.
✓ Branch 2 taken 589 times.
✓ Branch 3 taken 31 times.
620 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12063 {
12064
3/3
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 465 times.
✓ Branch 2 taken 31 times.
589 switch(tempsub[i].type)
12065 {
12066 case ssoTEXT:
12067 case ssoTEXTBOX:
12068 case ssoCURRENTITEMTEXT:
12069 case ssoCURRENTITEMCLASSTEXT:
12070
1/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
93 if(custom_subscreen[3].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[3].objects[i].dp1;
12071
12072 93 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12073 93 custom_subscreen[3].objects[i].dp1 = NULL;
12074 93 custom_subscreen[3].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12075 93 strcpy((char*)custom_subscreen[3].objects[i].dp1,(char*)tempsub[i].dp1);
12076 93 break;
12077
12078 case ssoLIFEMETER:
12079 {
12080 31 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12081
12082
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 17 times.
31 if(get_bit(deprecated_rules, 12) != 0)
12083 14 custom_subscreen[3].objects[i].d3=1;
12084 else
12085 17 custom_subscreen[3].objects[i].d3=0;
12086
12087 31 break;
12088 }
12089
12090 default:
12091 465 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12092 465 break;
12093 }
12094 589 }
12095
12096 31 custom_subscreen[3].ss_type=sstPASSIVE;
12097 31 sprintf(custom_subscreen[3].name, "Passive Subscreen (No Magic)");
12098 // memset(&custom_subscreen[3].objects[i],0,sizeof(subscreen_object));
12099 31 break;
12100 }
12101
12102 case ssdtZ3:
12103 {
12104 tempsub = z3_active_a;
12105 int32_t i;
12106
12107 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12108 {
12109 switch(tempsub[i].type)
12110 {
12111 case ssoTEXT:
12112 case ssoTEXTBOX:
12113 case ssoCURRENTITEMTEXT:
12114 case ssoCURRENTITEMCLASSTEXT:
12115 if(custom_subscreen[0].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[0].objects[i].dp1;
12116
12117 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12118 custom_subscreen[0].objects[i].dp1 = NULL;
12119 custom_subscreen[0].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12120 strcpy((char*)custom_subscreen[0].objects[i].dp1,(char*)tempsub[i].dp1);
12121 break;
12122
12123 case ssoLIFEMETER:
12124 {
12125 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12126
12127 if(get_bit(deprecated_rules, 12) != 0)
12128 custom_subscreen[0].objects[i].d3=1;
12129 else
12130 custom_subscreen[0].objects[i].d3=0;
12131
12132 break;
12133 }
12134
12135 default:
12136 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12137 break;
12138 }
12139 }
12140
12141 custom_subscreen[0].ss_type=sstACTIVE;
12142 // memset(&custom_subscreen[0].objects[i],0,sizeof(subscreen_object));
12143 tempsub = z3_active_ab;
12144
12145 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12146 {
12147 switch(tempsub[i].type)
12148 {
12149 case ssoTEXT:
12150 case ssoTEXTBOX:
12151 case ssoCURRENTITEMTEXT:
12152 case ssoCURRENTITEMCLASSTEXT:
12153 if(custom_subscreen[1].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[1].objects[i].dp1;
12154
12155 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12156 custom_subscreen[1].objects[i].dp1 = NULL;
12157 custom_subscreen[1].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12158 strcpy((char*)custom_subscreen[1].objects[i].dp1,(char*)tempsub[i].dp1);
12159 break;
12160
12161 case ssoLIFEMETER:
12162 {
12163 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12164
12165 if(get_bit(deprecated_rules, 12) != 0)
12166 custom_subscreen[1].objects[i].d3=1;
12167 else
12168 custom_subscreen[1].objects[i].d3=0;
12169
12170 break;
12171 }
12172
12173 default:
12174 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12175 break;
12176 }
12177 }
12178
12179 custom_subscreen[1].ss_type=sstACTIVE;
12180 // memset(&custom_subscreen[1].objects[i],0,sizeof(subscreen_object));
12181 tempsub = z3_passive_a;
12182
12183 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12184 {
12185 switch(tempsub[i].type)
12186 {
12187 case ssoTEXT:
12188 case ssoTEXTBOX:
12189 case ssoCURRENTITEMTEXT:
12190 case ssoCURRENTITEMCLASSTEXT:
12191 if(custom_subscreen[2].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[2].objects[i].dp1;
12192
12193 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12194 custom_subscreen[2].objects[i].dp1 = NULL;
12195 custom_subscreen[2].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12196 strcpy((char*)custom_subscreen[2].objects[i].dp1,(char*)tempsub[i].dp1);
12197 break;
12198
12199 case ssoLIFEMETER:
12200 {
12201 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12202
12203 if(get_bit(deprecated_rules, 12) != 0)
12204 custom_subscreen[2].objects[i].d3=1;
12205 else
12206 custom_subscreen[2].objects[i].d3=0;
12207
12208 break;
12209 }
12210
12211 default:
12212 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12213 break;
12214 }
12215 }
12216
12217 custom_subscreen[2].ss_type=sstPASSIVE;
12218 // memset(&custom_subscreen[2].objects[i],0,sizeof(subscreen_object));
12219 tempsub = z3_passive_ab;
12220
12221 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12222 {
12223 switch(tempsub[i].type)
12224 {
12225 case ssoTEXT:
12226 case ssoTEXTBOX:
12227 case ssoCURRENTITEMTEXT:
12228 case ssoCURRENTITEMCLASSTEXT:
12229 if(custom_subscreen[3].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[3].objects[i].dp1;
12230
12231 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12232 custom_subscreen[3].objects[i].dp1 = NULL;
12233 custom_subscreen[3].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12234 strcpy((char*)custom_subscreen[3].objects[i].dp1,(char*)tempsub[i].dp1);
12235 break;
12236
12237 case ssoLIFEMETER:
12238 {
12239 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12240
12241 if(get_bit(deprecated_rules, 12) != 0)
12242 custom_subscreen[3].objects[i].d3=1;
12243 else
12244 custom_subscreen[3].objects[i].d3=0;
12245
12246 break;
12247 }
12248
12249 default:
12250 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12251 break;
12252 }
12253 }
12254
12255 custom_subscreen[3].ss_type=sstPASSIVE;
12256 // memset(&custom_subscreen[3].objects[i],0,sizeof(subscreen_object));
12257 break;
12258 }
12259 }
12260
12261
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 124 times.
155 for(int32_t i=0; i<4; ++i)
12262 {
12263 124 purge_blank_subscreen_objects(&custom_subscreen[i]);
12264 124 }
12265
12266 31 return 0;
12267 }
12268
12269 extern script_data *ffscripts[NUMSCRIPTFFC];
12270 extern script_data *itemscripts[NUMSCRIPTITEM];
12271 extern script_data *guyscripts[NUMSCRIPTGUYS];
12272 extern script_data *wpnscripts[NUMSCRIPTWEAPONS];
12273 extern script_data *lwpnscripts[NUMSCRIPTWEAPONS];
12274 extern script_data *ewpnscripts[NUMSCRIPTWEAPONS];
12275 extern script_data *globalscripts[NUMSCRIPTGLOBAL];
12276 extern script_data *genericscripts[NUMSCRIPTSGENERIC];
12277 extern script_data *playerscripts[NUMSCRIPTPLAYER];
12278 extern script_data *screenscripts[NUMSCRIPTSCREEN];
12279 extern script_data *dmapscripts[NUMSCRIPTSDMAP];
12280 extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
12281 extern script_data *comboscripts[NUMSCRIPTSCOMBODATA];
12282 //script_data *wpnscripts[NUMSCRIPTWEAPONS]; //used only for old data
12283
12284
12285
12286 115 int32_t readffscript(PACKFILE *f, zquestheader *Header)
12287 {
12288 int32_t dummy;
12289 115 word s_version=0, s_cversion=0, zmeta_version=0;
12290 115 byte numscripts=0;
12291 115 numscripts=numscripts; //to avoid unused variables warnings
12292 int32_t ret;
12293
12294 //section version info
12295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(!p_igetw(&s_version,f))
12296 {
12297 return qe_invalid;
12298 }
12299
12300 115 FFCore.quest_format[vFFScript] = s_version;
12301
12302
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_igetw(&s_cversion,f))
12303 {
12304 return qe_invalid;
12305 }
12306
12307
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 36 times.
115 if(s_version >= 18)
12308 {
12309
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetw(&zmeta_version,f))
12310 {
12311 return qe_invalid;
12312 }
12313 36 }
12314
12315 //al_trace("Scripts version %d\n", s_version);
12316 //section size
12317
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_igetl(&dummy,f))
12318 {
12319 return qe_invalid;
12320 }
12321
12322 //ZScriptVersion::setVersion(s_version); ~this ideally, but there's no ZC/ZQuest defines...
12323 115 setZScriptVersion(s_version); //Lumped in zelda.cpp and in zquest.cpp as zquest can't link ZScriptVersion
12324 115 temp_ffscript_version = s_version;
12325 //miscQdata *the_misc;
12326
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 77 times.
115 if ( FFCore.quest_format[vLastCompile] < 13 ) FFCore.quest_format[vLastCompile] = s_version;
12327 115 al_trace("Loaded scripts last compiled in ZScript version: %d\n", (FFCore.quest_format[vLastCompile]));
12328
12329 //finally... section data
12330
2/2
✓ Branch 0 taken 57856 times.
✓ Branch 1 taken 103 times.
57971 for(int32_t i = 0; i < ((s_version < 2) ? NUMSCRIPTFFCOLD : NUMSCRIPTFFC); i++)
12331 {
12332 57856 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ffscripts[i], zmeta_version);
12333
12334
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if (ret)
12335 {
12336 return qe_invalid;
12337 }
12338 57856 }
12339
12340 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
12341 * This fixes changes to sprite jump values introduced in early 2.55 alphas.
12342 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
12343 * there was a version bump a week before a change that broke stuff.
12344 */
12345
7/8
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 67 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 36 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 36 times.
103 if(((Header->zelda_version < 0x253)||((Header->zelda_version == 0x253)&&(Header->build<33))||((Header->zelda_version > 0x253) && s_version < 12)))
12346 {
12347 139 set_qr(qr_SPRITE_JUMP_IS_TRUNCATED,1);
12348 139 }
12349
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 77 times.
113 if(s_version < 19)
12350 {
12351 77 set_qr(qr_FLUCTUATING_ENEMY_JUMP,1);
12352 77 }
12353
12354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(s_version > 1)
12355 {
12356
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 113 times.
29041 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
12357 {
12358 28928 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &itemscripts[i], zmeta_version);
12359
12360
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if (ret)
12361 {
12362 return qe_invalid;
12363 }
12364 28928 }
12365
12366
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 113 times.
29041 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
12367 {
12368 28928 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &guyscripts[i], zmeta_version);
12369
12370
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if (ret)
12371 {
12372 return qe_invalid;
12373 }
12374 28928 }
12375
12376
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 113 times.
29041 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12377 {
12378 28928 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &wpnscripts[i], zmeta_version);
12379
12380
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if (ret)
12381 {
12382 return qe_invalid;
12383 }
12384 28928 }
12385
12386
12387
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 113 times.
29041 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
12388 {
12389 28928 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &screenscripts[i], zmeta_version);
12390
12391
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if (ret)
12392 {
12393 return qe_invalid;
12394 }
12395 28928 }
12396
12397
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 77 times.
113 if(s_version > 16)
12398 {
12399
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 36 times.
324 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
12400 {
12401 288 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12402
12403
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 if (ret)
12404 {
12405 return qe_invalid;
12406 }
12407 288 }
12408 36 }
12409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 else if(s_version > 13)
12410 {
12411 for(int32_t i = 0; i < NUMSCRIPTGLOBAL255OLD; ++i)
12412 {
12413 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12414
12415 if (ret)
12416 {
12417 return qe_invalid;
12418 }
12419 }
12420
12421 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12422 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12423
12424 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12425 }
12426
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 else if(s_version > 4)
12427 {
12428
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i = 0; i < NUMSCRIPTGLOBAL253; ++i)
12429 {
12430 308 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12431
12432
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if (ret)
12433 {
12434 return qe_invalid;
12435 }
12436 308 }
12437
12438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12439
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12440
12441
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12442
12443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12444
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12445
12446
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12447
12448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12449
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete globalscripts[GLOBAL_SCRIPT_F6];
12450
12451
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12452
12453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12454
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12455
12456
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12457 77 }
12458 else
12459 {
12460 for(int32_t i = 0; i < NUMSCRIPTGLOBALOLD; i++)
12461 {
12462 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12463
12464 if (ret)
12465 {
12466 return qe_invalid;
12467 }
12468 }
12469
12470 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12471 delete globalscripts[GLOBAL_SCRIPT_ONSAVELOAD];
12472
12473 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] = new script_data();
12474
12475 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12476 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12477
12478 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12479
12480 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12481 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12482
12483 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12484
12485 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12486 delete globalscripts[GLOBAL_SCRIPT_F6];
12487
12488 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12489
12490 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12491 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12492
12493 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12494 }
12495
12496
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 77 times.
113 if(s_version > 10) //expanded the number of Player scripts to 5.
12497 {
12498
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 36 times.
216 for(int32_t i = 0; i < NUMSCRIPTPLAYER; i++)
12499 {
12500 180 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12501
12502
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if (ret)
12503 {
12504 return qe_invalid;
12505 }
12506 180 }
12507 36 }
12508 else
12509 {
12510
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 77 times.
308 for(int32_t i = 0; i < NUMSCRIPTHEROOLD; i++)
12511 {
12512 231 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12513
12514
1/2
✓ Branch 0 taken 231 times.
✗ Branch 1 not taken.
231 if (ret)
12515 {
12516 return qe_invalid;
12517 }
12518 231 }
12519
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(playerscripts[3] != NULL)
12520
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete playerscripts[3];
12521
12522
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 playerscripts[3] = new script_data();
12523
12524
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(playerscripts[4] != NULL)
12525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 delete playerscripts[4];
12526
12527
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 playerscripts[4] = new script_data();
12528 }
12529
3/4
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
113 if(s_version > 8 && s_version < 10)
12530 {
12531
12532 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12533 {
12534 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12535
12536 if (ret)
12537 {
12538 return qe_invalid;
12539 }
12540 }
12541 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12542 {
12543 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12544
12545 if (ret)
12546 {
12547 return qe_invalid;
12548 }
12549 }
12550
12551 }
12552
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 36 times.
113 if(s_version >= 10)
12553 {
12554
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 36 times.
9252 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12555 {
12556 9216 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &lwpnscripts[i], zmeta_version);
12557
12558
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if (ret)
12559 {
12560 return qe_invalid;
12561 }
12562 9216 }
12563
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 36 times.
9252 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12564 {
12565 9216 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12566
12567
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if (ret)
12568 {
12569 return qe_invalid;
12570 }
12571 9216 }
12572
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 36 times.
9252 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12573 {
12574 9216 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12575
12576
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if (ret)
12577 {
12578 return qe_invalid;
12579 }
12580 9216 }
12581
12582 36 }
12583
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 36 times.
113 if(s_version >=12)
12584 {
12585
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 36 times.
9252 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
12586 {
12587 9216 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &itemspritescripts[i], zmeta_version);
12588
12589
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if (ret)
12590 {
12591 return qe_invalid;
12592 }
12593 9216 }
12594 36 }
12595
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 36 times.
113 if(s_version >=15)
12596 {
12597
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 36 times.
18468 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
12598 {
12599 18432 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &comboscripts[i], zmeta_version);
12600
12601
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if (ret)
12602 {
12603 return qe_invalid;
12604 }
12605 18432 }
12606 36 }
12607
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 36 times.
113 if(s_version >19)
12608 {
12609 36 word numgenscripts = NUMSCRIPTSGENERIC;
12610
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetw(&numgenscripts,f))
12611 {
12612 return qe_invalid;
12613 }
12614
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 36 times.
18468 for(int32_t i = 0; i < numgenscripts; i++)
12615 {
12616 18432 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &genericscripts[i], zmeta_version);
12617
12618
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if (ret)
12619 {
12620 return qe_invalid;
12621 }
12622 18432 }
12623 36 }
12624
12625 /*
12626 else //Is this trip really necessary?
12627 {
12628 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12629 {
12630
12631 ewpnscripts[i] = NULL;
12632 }
12633 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12634 {
12635 dmapscripts[i] = NULL;
12636 }
12637 }
12638 */
12639
12640 113 }
12641
12642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(s_version > 2)
12643 {
12644 int32_t bufsize;
12645 113 p_igetl(&bufsize, f);
12646
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
113 if (bufsize < 0 || bufsize > 1024*1024*10)
12647 {
12648 // God help anyone storing more than 10MB of code in the script buffer.
12649 return qe_invalid;
12650 }
12651 113 char * buf = new char[bufsize+1];
12652 113 pfread(buf, bufsize, f);
12653 113 buf[bufsize]=0;
12654
12655
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 zScript = string(buf);
12656
12657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 delete[] buf;
12658 word numffcbindings;
12659 113 p_igetw(&numffcbindings, f);
12660
12661
2/2
✓ Branch 0 taken 1579 times.
✓ Branch 1 taken 113 times.
1692 for(int32_t i=0; i<numffcbindings; i++)
12662 {
12663 word id;
12664 1579 p_igetw(&id, f);
12665 1579 p_igetl(&bufsize, f);
12666
2/4
✓ Branch 0 taken 1579 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1579 times.
1579 if (bufsize < 0 || bufsize > 1024)
12667 return qe_invalid;
12668 1579 buf = new char[bufsize+1];
12669 1579 pfread(buf, bufsize, f);
12670 1579 buf[bufsize]=0;
12671
12672 //fix for buggy older saved quests -DD
12673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1579 times.
1579 if(id < NUMSCRIPTFFC-1)
12674 1579 ffcmap[id].scriptname = buf;
12675
12676
1/2
✓ Branch 0 taken 1579 times.
✗ Branch 1 not taken.
1579 delete[] buf;
12677 1579 }
12678
12679 word numglobalbindings;
12680 113 p_igetw(&numglobalbindings, f);
12681
12682
2/2
✓ Branch 0 taken 437 times.
✓ Branch 1 taken 113 times.
550 for(int32_t i=0; i<numglobalbindings; i++)
12683 {
12684 word id;
12685 437 p_igetw(&id, f);
12686 437 p_igetl(&bufsize, f);
12687
2/4
✓ Branch 0 taken 437 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 437 times.
✗ Branch 3 not taken.
437 if (bufsize < 0 || bufsize > 1024)
12688 return qe_invalid;
12689 437 buf = new char[bufsize+1];
12690 437 pfread(buf, bufsize, f);
12691 437 buf[bufsize]=0;
12692
12693 // id in principle should be valid, since slot assignment cannot assign a global script to a bogus slot.
12694 // However, because of a corruption bug, some 2.50.x quests contain bogus entries in the global bindings table.
12695 // Ignore these. -DD
12696
3/4
✓ Branch 0 taken 437 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 159 times.
✓ Branch 3 taken 278 times.
437 if(id >= 0 && id < NUMSCRIPTGLOBAL)
12697 {
12698 //Disable old '~Continue's, they'd wreak havoc. Bit messy, apologies ~Joe
12699
1/2
✓ Branch 0 taken 278 times.
✗ Branch 1 not taken.
278 if(strcmp(buf,"~Continue") == 0)
12700 {
12701 globalmap[id].scriptname = "";
12702
12703 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12704 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD]->disable();
12705 }
12706 else
12707 {
12708 278 globalmap[id].scriptname = buf;
12709 }
12710 278 }
12711
12712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 437 times.
437 delete[] buf;
12713 437 }
12714
12715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(s_version > 3)
12716 {
12717 word numitembindings;
12718 113 p_igetw(&numitembindings, f);
12719
12720
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 113 times.
211 for(int32_t i=0; i<numitembindings; i++)
12721 {
12722 word id;
12723 98 p_igetw(&id, f);
12724 98 p_igetl(&bufsize, f);
12725
2/4
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
98 if (bufsize < 0 || bufsize > 1024)
12726 return qe_invalid;
12727 98 buf = new char[bufsize+1];
12728 98 pfread(buf, bufsize, f);
12729 98 buf[bufsize]=0;
12730
12731 //fix this too
12732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
98 if(id <NUMSCRIPTITEM-1)
12733 98 itemmap[id].scriptname = buf;
12734
12735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
98 delete[] buf;
12736 98 }
12737 113 }
12738 //(v9+)
12739
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 36 times.
113 if(s_version > 8)
12740 {
12741 //npc scripts
12742 word numnpcbindings;
12743 36 p_igetw(&numnpcbindings, f);
12744
12745
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 36 times.
48 for(int32_t i=0; i<numnpcbindings; i++)
12746 {
12747 word id;
12748 12 p_igetw(&id, f);
12749 12 p_igetl(&bufsize, f);
12750
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if (bufsize < 0 || bufsize > 1024)
12751 return qe_invalid;
12752 12 buf = new char[bufsize+1];
12753 12 pfread(buf, bufsize, f);
12754 12 buf[bufsize]=0;
12755
12756 //fix this too
12757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(id <NUMSCRIPTGUYS-1)
12758 12 npcmap[id].scriptname = buf;
12759
12760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 delete[] buf;
12761 12 }
12762 //lweapon
12763 word numlwpnbindings;
12764 36 p_igetw(&numlwpnbindings, f);
12765
12766
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 36 times.
78 for(int32_t i=0; i<numlwpnbindings; i++)
12767 {
12768 word id;
12769 42 p_igetw(&id, f);
12770 42 p_igetl(&bufsize, f);
12771
2/4
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
42 if (bufsize < 0 || bufsize > 1024)
12772 return qe_invalid;
12773 42 buf = new char[bufsize+1];
12774 42 pfread(buf, bufsize, f);
12775 42 buf[bufsize]=0;
12776
12777 //fix this too
12778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(id <NUMSCRIPTWEAPONS-1)
12779 42 lwpnmap[id].scriptname = buf;
12780
12781
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 delete[] buf;
12782 42 }
12783 //eweapon
12784 word numewpnbindings;
12785 36 p_igetw(&numewpnbindings, f);
12786
12787
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 36 times.
99 for(int32_t i=0; i<numewpnbindings; i++)
12788 {
12789 word id;
12790 63 p_igetw(&id, f);
12791 63 p_igetl(&bufsize, f);
12792
2/4
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 63 times.
✗ Branch 3 not taken.
63 if (bufsize < 0 || bufsize > 1024)
12793 return qe_invalid;
12794 63 buf = new char[bufsize+1];
12795 63 pfread(buf, bufsize, f);
12796 63 buf[bufsize]=0;
12797
12798 //fix this too
12799
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(id <NUMSCRIPTWEAPONS-1)
12800 63 ewpnmap[id].scriptname = buf;
12801
12802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 delete[] buf;
12803 63 }
12804 //hero
12805 word numherobindings;
12806 36 p_igetw(&numherobindings, f);
12807
12808
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 36 times.
41 for(int32_t i=0; i<numherobindings; i++)
12809 {
12810 word id;
12811 5 p_igetw(&id, f);
12812 5 p_igetl(&bufsize, f);
12813
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if (bufsize < 0 || bufsize > 1024)
12814 return qe_invalid;
12815 5 buf = new char[bufsize+1];
12816 5 pfread(buf, bufsize, f);
12817 5 buf[bufsize]=0;
12818
12819 //fix this too
12820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(id <NUMSCRIPTPLAYER-1)
12821 5 playermap[id].scriptname = buf;
12822
12823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 delete[] buf;
12824 5 }
12825 //dmaps
12826 word numdmapbindings;
12827 36 p_igetw(&numdmapbindings, f);
12828
12829
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 36 times.
69 for(int32_t i=0; i<numdmapbindings; i++)
12830 {
12831 word id;
12832 33 p_igetw(&id, f);
12833 33 p_igetl(&bufsize, f);
12834
2/4
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
33 if (bufsize < 0 || bufsize > 1024)
12835 return qe_invalid;
12836 33 buf = new char[bufsize+1];
12837 33 pfread(buf, bufsize, f);
12838 33 buf[bufsize]=0;
12839
12840 //fix this too
12841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(id <NUMSCRIPTSDMAP-1)
12842 33 dmapmap[id].scriptname = buf;
12843
12844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 delete[] buf;
12845 33 }
12846 //screen
12847 word numscreenbindings;
12848 36 p_igetw(&numscreenbindings, f);
12849
12850
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 36 times.
73 for(int32_t i=0; i<numscreenbindings; i++)
12851 {
12852 word id;
12853 37 p_igetw(&id, f);
12854 37 p_igetl(&bufsize, f);
12855
2/4
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
37 if (bufsize < 0 || bufsize > 1024)
12856 return qe_invalid;
12857 37 buf = new char[bufsize+1];
12858 37 pfread(buf, bufsize, f);
12859 37 buf[bufsize]=0;
12860
12861 //fix this too
12862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(id <NUMSCRIPTSDMAP-1)
12863 37 screenmap[id].scriptname = buf;
12864
12865
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 delete[] buf;
12866 37 }
12867 36 }
12868
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 36 times.
113 if(s_version > 11)
12869 {
12870 word numspritebindings;
12871 36 p_igetw(&numspritebindings, f);
12872
12873
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 36 times.
46 for(int32_t i=0; i<numspritebindings; i++)
12874 {
12875 word id;
12876 10 p_igetw(&id, f);
12877 10 p_igetl(&bufsize, f);
12878
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
10 if (bufsize < 0 || bufsize > 1024)
12879 return qe_invalid;
12880 10 buf = new char[bufsize+1];
12881 10 pfread(buf, bufsize, f);
12882 10 buf[bufsize]=0;
12883
12884 //fix this too
12885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(id <NUMSCRIPTSDMAP-1)
12886 10 itemspritemap[id].scriptname = buf;
12887
12888
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 delete[] buf;
12889 10 }
12890 36 }
12891
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 36 times.
113 if(s_version >= 15)
12892 {
12893 word numcombobindings;
12894 36 p_igetw(&numcombobindings, f);
12895
12896
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 36 times.
59 for(int32_t i=0; i<numcombobindings; i++)
12897 {
12898 word id;
12899 23 p_igetw(&id, f);
12900 23 p_igetl(&bufsize, f);
12901
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if (bufsize < 0 || bufsize > 1024)
12902 return qe_invalid;
12903 23 buf = new char[bufsize+1];
12904 23 pfread(buf, bufsize, f);
12905 23 buf[bufsize]=0;
12906
12907 //fix this too
12908
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(id <NUMSCRIPTSCOMBODATA-1)
12909 23 comboscriptmap[id].scriptname = buf;
12910
12911
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 delete[] buf;
12912 23 }
12913 36 }
12914
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 36 times.
113 if(s_version > 19)
12915 {
12916 word numgenericbindings;
12917 36 p_igetw(&numgenericbindings, f);
12918
12919
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 36 times.
49 for(int32_t i=0; i<numgenericbindings; i++)
12920 {
12921 word id;
12922 13 p_igetw(&id, f);
12923 13 p_igetl(&bufsize, f);
12924
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
13 if (bufsize < 0 || bufsize > 1024)
12925 return qe_invalid;
12926 13 buf = new char[bufsize+1];
12927 13 pfread(buf, bufsize, f);
12928 13 buf[bufsize]=0;
12929
12930 //fix this too
12931
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(id <NUMSCRIPTSGENERIC-1)
12932 13 genericmap[id].scriptname = buf;
12933
12934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 delete[] buf;
12935 13 }
12936 36 }
12937 113 }
12938
12939 113 return 0;
12940 113 }
12941
12942 129 void reset_scripts()
12943 {
12944 #ifdef IS_PLAYER
12945 // We can't modify the script data while jit threads are possibly compiling them.
12946 void jit_shutdown();
12947 129 jit_shutdown();
12948 #endif
12949
12950 129 next_script_data_debug_id = 0;
12951
12952
2/2
✓ Branch 0 taken 66048 times.
✓ Branch 1 taken 129 times.
66177 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
12953 {
12954
2/2
✓ Branch 0 taken 42496 times.
✓ Branch 1 taken 23552 times.
66048 if (genericscripts[i]!=NULL) genericscripts[i]->disable();
12955
1/2
✓ Branch 0 taken 23552 times.
✗ Branch 1 not taken.
23552 else genericscripts[i] = new script_data();
12956 66048 }
12957
12958
2/2
✓ Branch 0 taken 66048 times.
✓ Branch 1 taken 129 times.
66177 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12959 {
12960
1/2
✓ Branch 0 taken 66048 times.
✗ Branch 1 not taken.
66048 if(ffscripts[i]!=NULL)
12961 {
12962 66048 ffscripts[i]->disable();
12963 66048 }
12964 else
12965 {
12966 ffscripts[i] = new script_data();
12967 }
12968 66048 }
12969
12970
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
12971 {
12972
1/2
✓ Branch 0 taken 33024 times.
✗ Branch 1 not taken.
33024 if(itemscripts[i]!=NULL)
12973 {
12974 33024 itemscripts[i]->disable();
12975 33024 }
12976 else
12977 {
12978 itemscripts[i] = new script_data();
12979 }
12980 33024 }
12981
12982
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
12983 {
12984
1/2
✓ Branch 0 taken 33024 times.
✗ Branch 1 not taken.
33024 if(guyscripts[i]!=NULL)
12985 {
12986 33024 guyscripts[i]->disable();
12987 33024 }
12988 else
12989 {
12990 guyscripts[i] = new script_data();
12991 }
12992 33024 }
12993
12994
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12995 {
12996
1/2
✓ Branch 0 taken 33024 times.
✗ Branch 1 not taken.
33024 if(wpnscripts[i]!=NULL)
12997 {
12998 33024 wpnscripts[i]->disable();
12999 33024 }
13000 else
13001 {
13002 wpnscripts[i] = new script_data();
13003 }
13004 33024 }
13005
13006
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
13007 {
13008
1/2
✓ Branch 0 taken 33024 times.
✗ Branch 1 not taken.
33024 if(screenscripts[i]!=NULL)
13009 {
13010 33024 screenscripts[i]->disable();
13011 33024 }
13012 else
13013 {
13014 screenscripts[i] = new script_data();
13015 }
13016 33024 }
13017
13018
2/2
✓ Branch 0 taken 1032 times.
✓ Branch 1 taken 129 times.
1161 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
13019 {
13020
1/2
✓ Branch 0 taken 1032 times.
✗ Branch 1 not taken.
1032 if(globalscripts[i]!=NULL)
13021 {
13022 1032 globalscripts[i]->disable();
13023 1032 }
13024 else
13025 {
13026 globalscripts[i] = new script_data();
13027 }
13028 1032 }
13029
13030
2/2
✓ Branch 0 taken 645 times.
✓ Branch 1 taken 129 times.
774 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
13031 {
13032
1/2
✓ Branch 0 taken 645 times.
✗ Branch 1 not taken.
645 if(playerscripts[i]!=NULL)
13033 {
13034 645 playerscripts[i]->disable();
13035 645 }
13036 else
13037 {
13038 playerscripts[i] = new script_data();
13039 }
13040 645 }
13041
13042
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13043 {
13044
1/2
✓ Branch 0 taken 33024 times.
✗ Branch 1 not taken.
33024 if(lwpnscripts[i]!=NULL)
13045 {
13046 33024 lwpnscripts[i]->disable();
13047 33024 }
13048 else
13049 {
13050 lwpnscripts[i] = new script_data();
13051 }
13052 33024 }
13053
13054
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13055 {
13056
1/2
✓ Branch 0 taken 33024 times.
✗ Branch 1 not taken.
33024 if(ewpnscripts[i]!=NULL)
13057 {
13058 33024 ewpnscripts[i]->disable();
13059 33024 }
13060 else
13061 {
13062 ewpnscripts[i] = new script_data();
13063 }
13064 33024 }
13065
13066
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
13067 {
13068
1/2
✓ Branch 0 taken 33024 times.
✗ Branch 1 not taken.
33024 if(dmapscripts[i]!=NULL)
13069 {
13070 33024 dmapscripts[i]->disable();
13071 33024 }
13072 else
13073 {
13074 dmapscripts[i] = new script_data();
13075 }
13076 33024 }
13077
13078
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
13079 {
13080
1/2
✓ Branch 0 taken 33024 times.
✗ Branch 1 not taken.
33024 if(itemspritescripts[i]!=NULL)
13081 {
13082 33024 itemspritescripts[i]->disable();
13083 33024 }
13084 else
13085 {
13086 itemspritescripts[i] = new script_data();
13087 }
13088 33024 }
13089
13090
2/2
✓ Branch 0 taken 66048 times.
✓ Branch 1 taken 129 times.
66177 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
13091 {
13092
1/2
✓ Branch 0 taken 66048 times.
✗ Branch 1 not taken.
66048 if(comboscripts[i]!=NULL)
13093 {
13094 66048 comboscripts[i]->disable();
13095 66048 }
13096 else
13097 {
13098 comboscripts[i] = new script_data();
13099 }
13100 66048 }
13101 129 }
13102
13103 extern script_command command_list[];
13104 248303 int32_t read_one_ffscript(PACKFILE *f, zquestheader *, int32_t script_index, word s_version, word , script_data **script, word zmeta_version)
13105 {
13106 //Please also update loadquest() when modifying this method -DD
13107 248303 char b33[34] = {0};
13108 248303 b33[33] = 0;
13109 248303 ffscript temp_script;
13110 248303 int32_t num_commands=1000;
13111
13112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 248303 times.
248303 if(s_version>=2)
13113 {
13114
2/4
✓ Branch 0 taken 248303 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 248303 times.
✗ Branch 3 not taken.
248303 if(!p_igetl(&num_commands,f))
13115 {
13116 return qe_invalid;
13117 }
13118 248303 }
13119
13120 #ifdef ZC_FUZZ
13121 const int32_t command_limit = 300000;
13122 #else
13123 248303 const int32_t command_limit = 10000000;
13124 #endif
13125
2/4
✓ Branch 0 taken 248303 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 248303 times.
✗ Branch 3 not taken.
248303 if (num_commands < 0 || num_commands > command_limit)
13126 {
13127 return qe_invalid;
13128 }
13129
13130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 248303 times.
248303 if((*script) != NULL)
13131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 248303 times.
248303 delete (*script);
13132
2/4
✓ Branch 0 taken 248303 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 248303 times.
✗ Branch 3 not taken.
248303 (*script) = new script_data(num_commands);
13133
13134
2/2
✓ Branch 0 taken 129492 times.
✓ Branch 1 taken 118811 times.
248303 if(s_version >= 16)
13135 {
13136
1/2
✓ Branch 0 taken 129492 times.
✗ Branch 1 not taken.
129492 zasm_meta temp_meta;
13137
13138
2/4
✓ Branch 0 taken 129492 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 129492 times.
✗ Branch 3 not taken.
129492 if(!p_igetw(&(temp_meta.zasm_v),f))
13139 {
13140 return qe_invalid;
13141 }
13142
13143
2/4
✓ Branch 0 taken 129492 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 129492 times.
✗ Branch 3 not taken.
129492 if(!p_igetw(&(temp_meta.meta_v),f))
13144 {
13145 return qe_invalid;
13146 }
13147
13148
2/4
✓ Branch 0 taken 129492 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 129492 times.
✗ Branch 3 not taken.
129492 if(!p_igetw(&(temp_meta.ffscript_v),f))
13149 {
13150 return qe_invalid;
13151 }
13152
13153
2/4
✓ Branch 0 taken 129492 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 129492 times.
✗ Branch 3 not taken.
129492 if(!p_getc(&(temp_meta.script_type),f))
13154 {
13155 return qe_invalid;
13156 }
13157
13158
2/2
✓ Branch 0 taken 1035936 times.
✓ Branch 1 taken 129492 times.
1165428 for(int32_t q = 0; q < 8; ++q)
13159 {
13160
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 978384 times.
1035936 if(zmeta_version < 3)
13161 {
13162
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 1899216 times.
1956768 for(int32_t c = 0; c < 33; ++c)
13163 {
13164
2/4
✓ Branch 0 taken 1899216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1899216 times.
✗ Branch 3 not taken.
1899216 if(!p_getc(&(b33[c]),f))
13165 {
13166 return qe_invalid;
13167 }
13168 1899216 }
13169
1/2
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
57552 temp_meta.run_idens[q].assign(b33);
13170 57552 }
13171 else
13172 {
13173
2/4
✓ Branch 0 taken 978384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 978384 times.
✗ Branch 3 not taken.
978384 if(!p_getcstr(&temp_meta.run_idens[q],f))
13174 {
13175 return qe_invalid;
13176 }
13177 }
13178 1035936 }
13179
13180
2/2
✓ Branch 0 taken 129492 times.
✓ Branch 1 taken 1035936 times.
1165428 for(int32_t q = 0; q < 8; ++q)
13181 {
13182
2/4
✓ Branch 0 taken 1035936 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1035936 times.
✗ Branch 3 not taken.
1035936 if(!p_getc(&(temp_meta.run_types[q]),f))
13183 {
13184 return qe_invalid;
13185 }
13186 1035936 }
13187
13188
2/4
✓ Branch 0 taken 129492 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 129492 times.
✗ Branch 3 not taken.
129492 if(!p_getc(&(temp_meta.flags),f))
13189 {
13190 return qe_invalid;
13191 }
13192
13193
2/4
✓ Branch 0 taken 129492 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 129492 times.
✗ Branch 3 not taken.
129492 if(!p_igetw(&(temp_meta.compiler_v1),f))
13194 {
13195 return qe_invalid;
13196 }
13197
13198
2/4
✓ Branch 0 taken 129492 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 129492 times.
✗ Branch 3 not taken.
129492 if(!p_igetw(&(temp_meta.compiler_v2),f))
13199 {
13200 return qe_invalid;
13201 }
13202
13203
2/4
✓ Branch 0 taken 129492 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 129492 times.
✗ Branch 3 not taken.
129492 if(!p_igetw(&(temp_meta.compiler_v3),f))
13204 {
13205 return qe_invalid;
13206 }
13207
13208
2/4
✓ Branch 0 taken 129492 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 129492 times.
✗ Branch 3 not taken.
129492 if(!p_igetw(&(temp_meta.compiler_v4),f))
13209 {
13210 return qe_invalid;
13211 }
13212
13213
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 122298 times.
129492 if(zmeta_version == 2)
13214 {
13215
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 237402 times.
244596 for(int32_t c = 0; c < 33; ++c)
13216 {
13217
2/4
✓ Branch 0 taken 237402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 237402 times.
✗ Branch 3 not taken.
237402 if(!p_getc(&b33[c],f))
13218 {
13219 return qe_invalid;
13220 }
13221 237402 }
13222
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 temp_meta.script_name.assign(b33);
13223
13224
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 237402 times.
244596 for(int32_t c = 0; c < 33; ++c)
13225 {
13226
2/4
✓ Branch 0 taken 237402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 237402 times.
✗ Branch 3 not taken.
237402 if(!p_getc(&b33[c],f))
13227 {
13228 return qe_invalid;
13229 }
13230 237402 }
13231
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 temp_meta.author.assign(b33);
13232 7194 }
13233
1/2
✓ Branch 0 taken 122298 times.
✗ Branch 1 not taken.
122298 else if(zmeta_version > 2)
13234 {
13235
2/4
✓ Branch 0 taken 122298 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 122298 times.
✗ Branch 3 not taken.
122298 if(!p_getcstr(&temp_meta.script_name,f))
13236 return qe_invalid;
13237
2/4
✓ Branch 0 taken 122298 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 122298 times.
✗ Branch 3 not taken.
122298 if(!p_getcstr(&temp_meta.author,f))
13238 return qe_invalid;
13239 122298 auto num_meta_attrib = (zmeta_version < 5 ? 4 : 10);
13240
2/2
✓ Branch 0 taken 1222980 times.
✓ Branch 1 taken 122298 times.
1345278 for(auto q = 0; q < num_meta_attrib; ++q)
13241 {
13242
2/4
✓ Branch 0 taken 1222980 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1222980 times.
✗ Branch 3 not taken.
1222980 if(!p_getcstr(&temp_meta.attributes[q],f))
13243 return qe_invalid;
13244
2/4
✓ Branch 0 taken 1222980 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1222980 times.
✗ Branch 3 not taken.
1222980 if(!p_getwstr(&temp_meta.attributes_help[q],f))
13245 return qe_invalid;
13246 1222980 }
13247
2/2
✓ Branch 0 taken 978384 times.
✓ Branch 1 taken 122298 times.
1100682 for(auto q = 0; q < 8; ++q)
13248 {
13249
2/4
✓ Branch 0 taken 978384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 978384 times.
✗ Branch 3 not taken.
978384 if(!p_getcstr(&temp_meta.attribytes[q],f))
13250 return qe_invalid;
13251
2/4
✓ Branch 0 taken 978384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 978384 times.
✗ Branch 3 not taken.
978384 if(!p_getwstr(&temp_meta.attribytes_help[q],f))
13252 return qe_invalid;
13253 978384 }
13254
2/2
✓ Branch 0 taken 978384 times.
✓ Branch 1 taken 122298 times.
1100682 for(auto q = 0; q < 8; ++q)
13255 {
13256
2/4
✓ Branch 0 taken 978384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 978384 times.
✗ Branch 3 not taken.
978384 if(!p_getcstr(&temp_meta.attrishorts[q],f))
13257 return qe_invalid;
13258
2/4
✓ Branch 0 taken 978384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 978384 times.
✗ Branch 3 not taken.
978384 if(!p_getwstr(&temp_meta.attrishorts_help[q],f))
13259 return qe_invalid;
13260 978384 }
13261
2/2
✓ Branch 0 taken 1956768 times.
✓ Branch 1 taken 122298 times.
2079066 for(auto q = 0; q < 16; ++q)
13262 {
13263
2/4
✓ Branch 0 taken 1956768 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1956768 times.
✗ Branch 3 not taken.
1956768 if(!p_getcstr(&temp_meta.usrflags[q],f))
13264 return qe_invalid;
13265
2/4
✓ Branch 0 taken 1956768 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1956768 times.
✗ Branch 3 not taken.
1956768 if(!p_getwstr(&temp_meta.usrflags_help[q],f))
13266 return qe_invalid;
13267 1956768 }
13268 122298 }
13269
2/2
✓ Branch 0 taken 122298 times.
✓ Branch 1 taken 7194 times.
129492 if(zmeta_version > 3)
13270 {
13271
2/2
✓ Branch 0 taken 978384 times.
✓ Branch 1 taken 122298 times.
1100682 for(auto q = 0; q < 8; ++q)
13272 {
13273
2/4
✓ Branch 0 taken 978384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 978384 times.
✗ Branch 3 not taken.
978384 if(!p_getcstr(&temp_meta.initd[q],f))
13274 return qe_invalid;
13275
2/4
✓ Branch 0 taken 978384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 978384 times.
✗ Branch 3 not taken.
978384 if(!p_getwstr(&temp_meta.initd_help[q],f))
13276 return qe_invalid;
13277 978384 }
13278
2/2
✓ Branch 0 taken 978384 times.
✓ Branch 1 taken 122298 times.
1100682 for(auto q = 0; q < 8; ++q)
13279 {
13280
2/4
✓ Branch 0 taken 978384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 978384 times.
✗ Branch 3 not taken.
978384 if(!p_getc(&temp_meta.initd_type[q],f))
13281 return qe_invalid;
13282 978384 }
13283 122298 }
13284 else
13285 {
13286
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 7194 times.
64746 for(auto q = 0; q < 8; ++q)
13287 {
13288
1/2
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
57552 temp_meta.initd[q] = temp_meta.run_idens[q];
13289 57552 }
13290 }
13291
13292
1/2
✓ Branch 0 taken 129492 times.
✗ Branch 1 not taken.
129492 (*script)->meta = temp_meta;
13293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129492 times.
129492 }
13294
13295
1/2
✓ Branch 0 taken 248303 times.
✗ Branch 1 not taken.
248303 temp_script.clear();
13296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21826437 times.
21826437 for(int32_t j=0; j<num_commands; j++)
13297 {
13298
2/4
✓ Branch 0 taken 21826437 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21826437 times.
✗ Branch 3 not taken.
21826437 if(!p_igetw(&(temp_script.command),f))
13299 {
13300 return qe_invalid;
13301 }
13302
13303
2/2
✓ Branch 0 taken 248303 times.
✓ Branch 1 taken 21578134 times.
21826437 if(temp_script.command == 0xFFFF)
13304 {
13305
1/2
✓ Branch 0 taken 248303 times.
✗ Branch 1 not taken.
248303 (*script)->zasm[j].clear();
13306 248303 break;
13307 }
13308 else
13309 {
13310
2/4
✓ Branch 0 taken 21578134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21578134 times.
✗ Branch 3 not taken.
21578134 if(!p_igetl(&(temp_script.arg1),f))
13311 {
13312 return qe_invalid;
13313 }
13314
13315
2/4
✓ Branch 0 taken 21578134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21578134 times.
✗ Branch 3 not taken.
21578134 if(!p_igetl(&(temp_script.arg2),f))
13316 {
13317 return qe_invalid;
13318 }
13319
13320
2/2
✓ Branch 0 taken 905513 times.
✓ Branch 1 taken 20672621 times.
21578134 if(s_version >= 21)
13321 {
13322 905513 uint32_t sz = 0;
13323
2/4
✓ Branch 0 taken 905513 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 905513 times.
✗ Branch 3 not taken.
905513 if(!p_igetl(&sz,f))
13324 {
13325 return qe_invalid;
13326 }
13327
2/2
✓ Branch 0 taken 3202 times.
✓ Branch 1 taken 902311 times.
905513 if(sz) //string found
13328 {
13329
1/2
✓ Branch 0 taken 3202 times.
✗ Branch 1 not taken.
3202 temp_script.strptr = new std::string();
13330 char dummy;
13331
2/2
✓ Branch 0 taken 232733 times.
✓ Branch 1 taken 3202 times.
235935 for(size_t q = 0; q < sz; ++q)
13332 {
13333
2/4
✓ Branch 0 taken 232733 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 232733 times.
✗ Branch 3 not taken.
232733 if(!p_getc(&dummy,f))
13334 {
13335 return qe_invalid;
13336 }
13337
1/2
✓ Branch 0 taken 232733 times.
✗ Branch 1 not taken.
232733 temp_script.strptr->push_back(dummy);
13338 232733 }
13339 3202 }
13340
2/4
✓ Branch 0 taken 905513 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 905513 times.
✗ Branch 3 not taken.
905513 if(!p_igetl(&sz,f))
13341 {
13342 return qe_invalid;
13343 }
13344
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 905412 times.
905513 if(sz) //vector found
13345 {
13346
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 temp_script.vecptr = new std::vector<int32_t>();
13347 int32_t dummy;
13348
2/2
✓ Branch 0 taken 1487 times.
✓ Branch 1 taken 101 times.
1588 for(size_t q = 0; q < sz; ++q)
13349 {
13350
2/4
✓ Branch 0 taken 1487 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1487 times.
✗ Branch 3 not taken.
1487 if(!p_igetl(&dummy,f))
13351 {
13352 return qe_invalid;
13353 }
13354
1/2
✓ Branch 0 taken 1487 times.
✗ Branch 1 not taken.
1487 temp_script.vecptr->push_back(dummy);
13355 1487 }
13356 101 }
13357 905513 }
13358
13359
1/2
✓ Branch 0 taken 21578134 times.
✗ Branch 1 not taken.
21578134 temp_script.give((*script)->zasm[j]);
13360 }
13361
1/2
✓ Branch 0 taken 21578134 times.
✗ Branch 1 not taken.
21578134 temp_script.clear();
13362 21578134 }
13363
13364 248303 return 0;
13365 248303 }
13366
13367 extern SAMPLE customsfxdata[WAV_COUNT];
13368 extern uint8_t customsfxflag[WAV_COUNT>>3];
13369 extern int32_t sfxdat;
13370 extern DATAFILE *sfxdata;
13371 const char *old_sfx_string[Z35] =
13372 {
13373 "Arrow", "Sword beam", "Bomb blast", "Boomerang", "Subscreen cursor",
13374 "Shield is hit", "Item chime", "Roar (Dodongo, Gohma)", "Shutter", "Enemy dies",
13375 "Enemy is hit", "Low hearts warning", "Fire", "Ganon's fanfare", "Boss is hit", "Hammer",
13376 "Hookshot", "Message", "Player is hit", "Item fanfare", "Bomb placed", "Item pickup",
13377 "Refill", "Roar (Aquamentus, Gleeok, Ganon)", "Item pickup 2", "Ocean ambience",
13378 "Secret chime", "Player dies", "Stairs", "Sword", "Roar (Manhandla, Digdogger, Patra)",
13379 "Wand magic", "Whistle", "Zelda's fanfare", "Charging weapon", "Charging weapon 2",
13380 "Divine Fire", "Enemy falls from ceiling", "Divine Escape", "Fireball", "Tall Grass slashed",
13381 "Pound pounded", "Hover Boots", "Ice magic", "Jump", "Lens of Truth off", "Lens of Truth on",
13382 "Divine Protection shield", "Divine Protection 2", "Push block", "Rock", "Spell rocket down",
13383 "Spell rocket up", "Sword spin attack", "Splash", "Summon magic", "Sword tapping",
13384 "Sword tapping (secret)", "Whistle whirlwind", "Cane of Byrna orbit"
13385 };
13386 char *sfx_string[WAV_COUNT];
13387
13388 113 int32_t readsfx(PACKFILE *f, zquestheader *Header)
13389 {
13390 //these are here to bypass compiler warnings about unused arguments
13391 113 Header=Header;
13392
13393 int32_t dummy;
13394 113 word s_version=0, s_cversion=0;
13395 //int32_t ret;
13396 SAMPLE temp_sample;
13397 113 temp_sample.loop_start=0;
13398 113 temp_sample.loop_end=0;
13399 113 temp_sample.param=0;
13400
13401 //section version info
13402
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(!p_igetw(&s_version,f))
13403 {
13404 return qe_invalid;
13405 }
13406
13407 113 FFCore.quest_format[vSFX] = s_version;
13408
13409 //al_trace("SFX version %d\n", s_version);
13410
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&s_cversion,f))
13411 {
13412 return qe_invalid;
13413 }
13414
13415 //section size
13416
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetl(&dummy,f))
13417 {
13418 return qe_invalid;
13419 }
13420
13421 /* HIGHLY UNORTHODOX UPDATING THING, by L
13422 * This fixes quests made before revision 411 (such as the 'Lost Isle Build'),
13423 * where the meaning of GOTOLESS changed. It also coincided with V_SFX
13424 * changing from 1 to 2.
13425 */
13426
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(s_version < 2)
13427 set_qr(qr_GOTOLESSNOTEQUAL,1);
13428
13429 /* End highly unorthodox updating thing */
13430
13431 113 int32_t wavcount = WAV_COUNT;
13432
13433
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(s_version < 6)
13434 wavcount = 128;
13435
13436 uint8_t tempflag[WAV_COUNT>>3];
13437
13438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(s_version < 4)
13439 {
13440 memset(tempflag, 0xFF, WAV_COUNT>>3);
13441 }
13442 else
13443 {
13444
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(s_version < 6)
13445 memset(tempflag, 0, WAV_COUNT>>3);
13446
13447
2/2
✓ Branch 0 taken 3616 times.
✓ Branch 1 taken 113 times.
3729 for(int32_t i=0; i<(wavcount>>3); i++)
13448 {
13449 3616 p_getc(&tempflag[i], f);
13450 3616 }
13451
13452 }
13453
13454
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(s_version>4)
13455 {
13456
2/2
✓ Branch 0 taken 28815 times.
✓ Branch 1 taken 113 times.
28928 for(int32_t i=1; i<WAV_COUNT; i++)
13457 {
13458 28815 sprintf(sfx_string[i],"s%03d",i);
13459
13460
2/2
✓ Branch 0 taken 22035 times.
✓ Branch 1 taken 6780 times.
28815 if((i<Z35))
13461 6780 strcpy(sfx_string[i], old_sfx_string[i-1]);
13462
13463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28815 times.
28815 if(i>=wavcount)
13464 continue;
13465
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 25743 times.
28815 if(get_bit(tempflag, i-1))
13466 {
13467 char tempname[36];
13468
13469
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if(!pfread(tempname, 36, f))
13470 {
13471 return qe_invalid;
13472 }
13473
13474 3072 sfx_string[i][0] = '\0';
13475 3072 strncat(sfx_string[i], tempname, 36 - 1);
13476 3072 }
13477 else
13478 {
13479 25743 sprintf(sfx_string[i],"s%03d",i);
13480
13481
2/2
✓ Branch 0 taken 21165 times.
✓ Branch 1 taken 4578 times.
25743 if(i<Z35)
13482 4578 strcpy(sfx_string[i], old_sfx_string[i-1]);
13483 25743 sfx_string[i][35] = 0; //Force NULL Termination
13484 }
13485 28815 }
13486 113 }
13487 else
13488 {
13489 for(int32_t i=1; i<WAV_COUNT; i++)
13490 {
13491 sprintf(sfx_string[i],"s%03d",i);
13492
13493 if(i<Z35)
13494 strcpy(sfx_string[i], old_sfx_string[i-1]);
13495 }
13496 }
13497
13498 //finally... section data
13499
2/2
✓ Branch 0 taken 28815 times.
✓ Branch 1 taken 113 times.
28928 for(int32_t i=1; i<wavcount; i++)
13500 {
13501
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 25743 times.
28815 if(get_bit(tempflag, i-1))
13502 {
13503
13504
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if(!p_igetl(&dummy,f))
13505 {
13506 return qe_invalid;
13507 }
13508
13509 3072 (temp_sample.bits) = dummy;
13510
13511
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if(!p_igetl(&dummy,f))
13512 {
13513 return qe_invalid;
13514 }
13515
13516 3072 (temp_sample.stereo) = dummy;
13517
13518
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if(!p_igetl(&dummy,f))
13519 {
13520 return qe_invalid;
13521 }
13522
13523 3072 (temp_sample.freq) = dummy;
13524
13525
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if(!p_igetl(&dummy,f))
13526 {
13527 return qe_invalid;
13528 }
13529
13530 3072 (temp_sample.priority) = dummy;
13531
13532
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if(!p_igetl(&(temp_sample.len),f))
13533 {
13534 return qe_invalid;
13535 }
13536
13537
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if(!p_igetl(&(temp_sample.loop_start),f))
13538 {
13539 return qe_invalid;
13540 }
13541
13542
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if(!p_igetl(&(temp_sample.loop_end),f))
13543 {
13544 return qe_invalid;
13545 }
13546
13547
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if(!p_igetl(&(temp_sample.param),f))
13548 {
13549 return qe_invalid;
13550 }
13551
13552 // al_trace("F%i: L%i\n",i,temp_sample.len);
13553 // temp_sample.data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13554 3072 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13555
2/4
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3072 times.
3072 if (len < 0 || len > 10000000)
13556 {
13557 return qe_invalid;
13558 }
13559 3072 temp_sample.data = calloc(len,1);
13560
13561
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if(s_version < 3)
13562 len = (temp_sample.bits==8?1:2)*temp_sample.len;
13563
13564 //old-style, non-portable loading (Bad Allegro! Bad!!) -DD
13565
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3072 times.
3072 if(s_version < 2)
13566 {
13567 if(!pfread(temp_sample.data, len,f))
13568 {
13569 return qe_invalid;
13570 }
13571 }
13572 else
13573 {
13574 //re-endianfy the data
13575 3072 int32_t wordstoread = len / sizeof(word);
13576
13577
2/2
✓ Branch 0 taken 89161498 times.
✓ Branch 1 taken 3072 times.
89164570 for(int32_t j=0; j<wordstoread; j++)
13578 {
13579 word temp;
13580
13581
1/2
✓ Branch 0 taken 89161498 times.
✗ Branch 1 not taken.
89161498 if(!p_igetw(&temp, f))
13582 {
13583 return qe_invalid;
13584 }
13585
13586 89161498 ((word *)temp_sample.data)[j] = temp;
13587 89161498 }
13588 }
13589 3072 }
13590
2/2
✓ Branch 0 taken 4578 times.
✓ Branch 1 taken 21165 times.
25743 else if(i < Z35)
13591 {
13592 4578 SAMPLE* datsamp = (SAMPLE*)(sfxdata[i].dat);
13593 4578 memcpy(&temp_sample, datsamp, sizeof(SAMPLE));
13594 4578 set_bit(tempflag, i-1, 1);
13595 4578 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13596 4578 temp_sample.data = calloc(len,1);
13597 4578 memcpy(temp_sample.data, datsamp->data, len);
13598 4578 }
13599 21165 else continue;
13600
13601
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7650 times.
7650 if(customsfxdata[i].data!=NULL)
13602 {
13603 // delete [] customsfxdata[i].data;
13604 7650 free(customsfxdata[i].data);
13605 7650 }
13606
13607 // customsfxdata[i].data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13608 7650 int32_t len2 = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13609 7650 customsfxdata[i].data = calloc(len2,1);
13610 7650 customsfxdata[i].bits = temp_sample.bits;
13611 7650 customsfxdata[i].stereo = temp_sample.stereo;
13612 7650 customsfxdata[i].freq = temp_sample.freq;
13613 7650 customsfxdata[i].priority = temp_sample.priority;
13614 7650 customsfxdata[i].len = temp_sample.len;
13615 7650 customsfxdata[i].loop_start = temp_sample.loop_start;
13616 7650 customsfxdata[i].loop_end = temp_sample.loop_end;
13617 7650 customsfxdata[i].param = temp_sample.param;
13618 7650 int32_t cpylen = len2;
13619
13620
1/2
✓ Branch 0 taken 7650 times.
✗ Branch 1 not taken.
7650 if(s_version<3)
13621 {
13622 cpylen = (temp_sample.bits==8?1:2)*temp_sample.len;
13623 al_trace("WARNING: Quest SFX %d is in stereo, and may be corrupt.\n",i);
13624 }
13625
13626 7650 memcpy(customsfxdata[i].data,temp_sample.data,cpylen);
13627
13628 7650 free(temp_sample.data);
13629 7650 }
13630
13631 113 memcpy(customsfxflag, tempflag, WAV_COUNT>>3);
13632
13633 113 sfxdat=0;
13634 113 return 0;
13635 113 }
13636
13637 129 void setupsfx()
13638 {
13639
2/2
✓ Branch 0 taken 32895 times.
✓ Branch 1 taken 129 times.
33024 for(int32_t i=1; i<WAV_COUNT; i++)
13640 {
13641 32895 sprintf(sfx_string[i],"s%03d",i);
13642
13643
2/2
✓ Branch 0 taken 25155 times.
✓ Branch 1 taken 7740 times.
32895 if(i<Z35)
13644 {
13645 7740 strcpy(sfx_string[i], old_sfx_string[i-1]);
13646 7740 }
13647
13648 32895 memset(customsfxflag, 0, WAV_COUNT>>3);
13649
13650 32895 int32_t j=i;
13651
13652
2/2
✓ Branch 0 taken 7869 times.
✓ Branch 1 taken 25026 times.
32895 if(i>Z35)
13653 {
13654 25026 i=Z35;
13655 25026 }
13656
13657 32895 SAMPLE *temp_sample = (SAMPLE *)sfxdata[i].dat;
13658
13659
2/2
✓ Branch 0 taken 11730 times.
✓ Branch 1 taken 21165 times.
32895 if(customsfxdata[j].data!=NULL)
13660 {
13661 // delete [] customsfxdata[j].data;
13662 21165 free(customsfxdata[j].data);
13663 21165 }
13664
13665 // customsfxdata[j].data = new byte[(temp_sample->bits==8?1:2)*temp_sample->len];
13666 32895 customsfxdata[j].data = calloc((temp_sample->bits==8?1:2)*(temp_sample->stereo == 0 ? 1 : 2)*temp_sample->len,1);
13667 32895 customsfxdata[j].bits = temp_sample->bits;
13668 32895 customsfxdata[j].stereo = temp_sample->stereo;
13669 32895 customsfxdata[j].freq = temp_sample->freq;
13670 32895 customsfxdata[j].priority = temp_sample->priority;
13671 32895 customsfxdata[j].len = temp_sample->len;
13672 32895 customsfxdata[j].loop_start = temp_sample->loop_start;
13673 32895 customsfxdata[j].loop_end = temp_sample->loop_end;
13674 32895 customsfxdata[j].param = temp_sample->param;
13675 32895 memcpy(customsfxdata[j].data, (temp_sample->data), (temp_sample->bits==8?1:2)*(temp_sample->stereo==0 ? 1 : 2)*temp_sample->len);
13676 32895 i=j;
13677 32895 }
13678 129 }
13679
13680 extern char *guy_string[eMAXGUYS];
13681 extern const char *old_guy_string[OLDMAXGUYS];
13682
13683 129 int32_t readguys(PACKFILE *f, zquestheader *Header)
13684 {
13685 dword dummy;
13686 word guy_cversion;
13687 129 word guyversion=0;
13688
13689
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(Header->zelda_version >= 0x193)
13690 {
13691 //section version info
13692
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&guyversion,f))
13693 {
13694 return qe_invalid;
13695 }
13696
13697 125 FFCore.quest_format[vGuys] = guyversion;
13698
13699 //al_trace("Guys version %d\n", guyversion);
13700
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&guy_cversion,f))
13701 {
13702 return qe_invalid;
13703 }
13704 125 al_trace("Guy CVersion is: %d\n", guy_cversion);
13705 //section size
13706
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&dummy,f))
13707 {
13708 return qe_invalid;
13709 }
13710 125 }
13711
13712
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(guyversion > 3)
13713 {
13714
2/2
✓ Branch 0 taken 57856 times.
✓ Branch 1 taken 113 times.
57969 for(int32_t i=0; i<MAXGUYS; i++)
13715 {
13716 char tempname[64];
13717
13718 // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
13719 // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
13720
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 57856 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
57856 if(guyversion < 23 && i >= OLDBETAMAXGUYS)
13721 {
13722 memset(tempname, 0, sizeof(char)*64);
13723 sprintf(tempname, "e%03d", i);
13724 strcpy(guy_string[i], tempname);
13725
13726 continue;
13727 }
13728
13729
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!pfread(tempname, 64, f))
13730 {
13731 return qe_invalid;
13732 }
13733
13734 // Don't retain names of uneditable enemy entries!
13735 // for version upgrade to 2.5
13736
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 57856 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
57856 if(guyversion < 23 && i >= 177)
13737 {
13738 // some of the older builds have names such as 'zz123',
13739 // (this order gets messed up with some eXXX and some zzXXX)
13740 // so let's update to the newer naming convection. -Gleeok
13741 char tmpbuf[64];
13742 memset(tmpbuf, 0, sizeof(char)*64);
13743 sprintf(tmpbuf, "zz%03d", i);
13744
13745 if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
13746 {
13747 memset(tempname, 0, sizeof(char)*64);
13748 sprintf(tempname, "e%03d", i);
13749 }
13750 }
13751
13752
6/6
✓ Branch 0 taken 20001 times.
✓ Branch 1 taken 37855 times.
✓ Branch 2 taken 18984 times.
✓ Branch 3 taken 1017 times.
✓ Branch 4 taken 15955 times.
✓ Branch 5 taken 3029 times.
57856 if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
13753 {
13754 54827 guy_string[i][0] = '\0';
13755 54827 strncat(guy_string[i], tempname, 64 - 1);
13756 54827 }
13757 else
13758 {
13759 3029 strcpy(guy_string[i],old_guy_string[i]);
13760 }
13761 57856 }
13762 113 }
13763 else
13764 {
13765
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 16 times.
8208 for(int32_t i=0; i<eMAXGUYS; i++)
13766 {
13767 8192 sprintf(guy_string[i],"zz%03d",i);
13768 8192 }
13769
13770
2/2
✓ Branch 0 taken 2832 times.
✓ Branch 1 taken 16 times.
2848 for(int32_t i=0; i<OLDMAXGUYS; i++)
13771 {
13772 2832 strcpy(guy_string[i],old_guy_string[i]);
13773 2832 }
13774 }
13775
13776
13777 //finally... section data
13778 129 init_guys(guyversion); //using default data for now...
13779
13780 // Goriya guy fix
13781
3/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
13782 {
13783
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 12 times.
16 if(get_qr(qr_NEWENEMYTILES))
13784 {
13785 12 guysbuf[gGORIYA].tile=130;
13786 12 guysbuf[gGORIYA].e_tile=130;
13787 12 }
13788 16 }
13789
13790
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(Header->zelda_version < 0x193)
13791 {
13792
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(get_bit(deprecated_rules,46))
13793 {
13794 guysbuf[eDODONGO].cset=14;
13795 guysbuf[eDODONGO].bosspal=spDIG;
13796 }
13797 4 }
13798 // Not sure when this first changed, but it's necessary for 2.10, at least
13799 // @TODO: @BUG:1.92 - 1.84? Figure this out exactly for the final 2.50 release.
13800 //2.10 Fixes
13801
3/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<18)))
13802 {
13803 16 guysbuf[eWWIZ].editorflags |= ENEMY_FLAG5;
13804 16 guysbuf[eMOLDORM].editorflags |= ENEMY_FLAG6;
13805 16 guysbuf[eMANHAN].editorflags |= ENEMY_FLAG6;
13806 16 guysbuf[eCENT1].misc3 = 1;
13807 16 guysbuf[eCENT2].misc3 = 1;
13808 16 }
13809
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((Header->zelda_version <= 0x255) || (Header->zelda_version == 0x255 && Header->build < 47) )
13810 {
13811 129 guysbuf[eWPOLSV].defense[edefWhistle] = ed1HKO;
13812 129 }
13813
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(Header->zelda_version <= 0x210)
13814 {
13815 16 guysbuf[eGLEEOK1F].misc6 = 16;
13816 16 guysbuf[eGLEEOK2F].misc6 = 16;
13817 16 guysbuf[eGLEEOK3F].misc6 = 16;
13818 16 guysbuf[eGLEEOK4F].misc6 = 16;
13819
13820 16 guysbuf[eWIZ1].misc4 = 1; //only set the enemy that needs backward compat, not all of them.
13821 16 guysbuf[eBATROBE].misc4 = 1;
13822 //guysbuf[eSUMMONER].misc4 = 1;
13823 16 guysbuf[eWWIZ].misc4 = 1;
13824 16 guysbuf[eDODONGO].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13825 16 guysbuf[eDODONGOBS].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13826 16 }
13827
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(Header->zelda_version == 0x190)
13828 {
13829 4 al_trace("Setting Tribble Properties for Version: %x", Header->zelda_version);
13830 4 guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13831 4 guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13832 4 }
13833
13834 // The versions here may not be correct
13835 // zelda_version>=0x211 handled at guyversion<24
13836
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(Header->zelda_version <= 0x190)
13837 {
13838 4 guysbuf[eCENT1].misc3 = 0;
13839 4 guysbuf[eCENT2].misc3 = 0;
13840 4 guysbuf[eMOLDORM].misc2 = 0;
13841 //guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13842 //guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13843 4 }
13844
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 else if(Header->zelda_version <= 0x210)
13845 {
13846 12 guysbuf[eCENT1].misc3 = 1;
13847 12 guysbuf[eCENT2].misc3 = 1;
13848 12 guysbuf[eMOLDORM].misc2 = 0;
13849 12 }
13850
13851
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if ( Header->zelda_version < 0x211 ) //Default rest rates for phantom ghinis, peahats and keese in < 2.50 quests
13852 {
13853 16 guysbuf[eKEESE1].misc16 = 120;
13854 16 guysbuf[eKEESE2].misc16 = 120;
13855 16 guysbuf[eKEESE3].misc16 = 120;
13856 16 guysbuf[eKEESETRIB].misc16 = 120;
13857 16 guysbuf[eKEESE1].misc17 = 16;
13858 16 guysbuf[eKEESE2].misc17 = 16;
13859 16 guysbuf[eKEESE3].misc17 = 16;
13860 16 guysbuf[eKEESETRIB].misc17 = 16;
13861
13862 16 guysbuf[ePEAHAT].misc16 = 80;
13863 16 guysbuf[ePEAHAT].misc17 = 16;
13864
13865 16 guysbuf[eGHINI2].misc16 = 120;
13866 16 guysbuf[eGHINI2].misc17 = 10;
13867
13868 16 }
13869
13870
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 113 times.
129 if(guyversion<=2)
13871 {
13872 16 return readherosprites2(f, guyversion==2?0:-1, 0);
13873 }
13874
13875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(guyversion > 3)
13876 {
13877 guydata tempguy;
13878
13879
2/2
✓ Branch 0 taken 57856 times.
✓ Branch 1 taken 113 times.
57969 for(int32_t i=0; i<MAXGUYS; i++)
13880 {
13881
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 23) // May 2012 : 512 max enemies
13882 {
13883 if(i >= OLDBETAMAXGUYS)
13884 {
13885 memset(&guysbuf[i], 0, sizeof(guydata));
13886 continue;
13887 }
13888 }
13889
13890 57856 memset(&tempguy, 0, sizeof(guydata));
13891
13892
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.flags),f))
13893 {
13894 return qe_invalid;
13895 }
13896
13897
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.flags2),f))
13898 {
13899 return qe_invalid;
13900 }
13901
13902
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if ( guyversion >= 36 ) //expanded tiles
13903 {
13904
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.tile),f))
13905 {
13906 return qe_invalid;
13907 }
13908 18432 }
13909 else
13910 {
13911
1/2
✓ Branch 0 taken 39424 times.
✗ Branch 1 not taken.
39424 if(!p_igetw(&(tempguy.tile),f))
13912 {
13913 return qe_invalid;
13914 }
13915 }
13916
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&(tempguy.width),f))
13917 {
13918 return qe_invalid;
13919 }
13920
13921
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&(tempguy.height),f))
13922 {
13923 return qe_invalid;
13924 }
13925
13926
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if ( guyversion >= 36 ) //expanded tiles
13927 {
13928
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.s_tile),f))
13929 {
13930 return qe_invalid;
13931 }
13932 18432 }
13933 else
13934 {
13935
1/2
✓ Branch 0 taken 39424 times.
✗ Branch 1 not taken.
39424 if(!p_igetw(&(tempguy.s_tile),f))
13936 {
13937 return qe_invalid;
13938 }
13939 }
13940
13941
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&(tempguy.s_width),f))
13942 {
13943 return qe_invalid;
13944 }
13945
13946
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&(tempguy.s_height),f))
13947 {
13948 return qe_invalid;
13949 }
13950
13951
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if ( guyversion >= 36 ) //expanded tiles
13952 {
13953
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.e_tile),f))
13954 {
13955 return qe_invalid;
13956 }
13957 18432 }
13958 else
13959 {
13960
1/2
✓ Branch 0 taken 39424 times.
✗ Branch 1 not taken.
39424 if(!p_igetw(&(tempguy.e_tile),f))
13961 {
13962 return qe_invalid;
13963 }
13964 }
13965
13966
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&(tempguy.e_width),f))
13967 {
13968 return qe_invalid;
13969 }
13970
13971
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&(tempguy.e_height),f))
13972 {
13973 return qe_invalid;
13974 }
13975
13976
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.hp),f))
13977 {
13978 return qe_invalid;
13979 }
13980
13981
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.family),f))
13982 {
13983 return qe_invalid;
13984 }
13985
13986
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 57856 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
57856 if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
13987 {
13988 if(get_qr(qr_NEWENEMYTILES))
13989 {
13990 tempguy.s_tile=tempguy.e_tile+120;
13991 tempguy.s_width=tempguy.e_width;
13992 tempguy.s_height=tempguy.e_height;
13993 }
13994 else tempguy.s_tile=860;
13995 }
13996
13997
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.cset),f))
13998 {
13999 return qe_invalid;
14000 }
14001
14002
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.anim),f))
14003 {
14004 return qe_invalid;
14005 }
14006
14007
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.e_anim),f))
14008 {
14009 return qe_invalid;
14010 }
14011
14012
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.frate),f))
14013 {
14014 return qe_invalid;
14015 }
14016
14017
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.e_frate),f))
14018 {
14019 return qe_invalid;
14020 }
14021
14022
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 13) // April 2009
14023 {
14024 if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
14025 {
14026 tempguy.frate *= 2;
14027 tempguy.e_frate *= 2;
14028 }
14029 }
14030
14031
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 14) // May 1 2009
14032 {
14033 if(tempguy.anim==a2FRMSLOW)
14034 {
14035 tempguy.anim=a2FRM;
14036 tempguy.frate *= 2;
14037 }
14038
14039 if(tempguy.e_anim==a2FRMSLOW)
14040 {
14041 tempguy.e_anim=a2FRM;
14042 tempguy.e_frate *= 2;
14043 }
14044
14045 if(tempguy.anim==aFLIPSLOW)
14046 {
14047 tempguy.anim=aFLIP;
14048 tempguy.frate *= 2;
14049 }
14050
14051 if(tempguy.e_anim==aFLIPSLOW)
14052 {
14053 tempguy.e_anim=aFLIP;
14054 tempguy.e_frate *= 2;
14055 }
14056
14057 if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
14058
14059 if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
14060
14061 if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
14062 {
14063 tempguy.anim=a4FRM4DIR;
14064 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14065 }
14066
14067 if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
14068 {
14069 tempguy.e_anim=a4FRM4DIR;
14070 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14071 }
14072 }
14073
14074
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.dp),f))
14075 {
14076 return qe_invalid;
14077 }
14078
14079 //correction for guy fire
14080
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 6)
14081 {
14082 if(i == gFIRE)
14083 tempguy.dp = 2;
14084 }
14085
14086
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.wdp),f))
14087 {
14088 return qe_invalid;
14089 }
14090
14091
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.weapon),f))
14092 {
14093 return qe_invalid;
14094 }
14095
14096 //correction for bosses using triple, "rising" fireballs
14097
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 5)
14098 {
14099 if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
14100 i == eGOHMA3 || i == eGOHMA4)
14101 {
14102 if(tempguy.weapon == ewFireball)
14103 tempguy.weapon = ewFireball2;
14104 }
14105 }
14106
14107
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.rate),f))
14108 {
14109 return qe_invalid;
14110 }
14111
14112
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.hrate),f))
14113 {
14114 return qe_invalid;
14115 }
14116
14117
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.step),f))
14118 {
14119 return qe_invalid;
14120 }
14121
14122 // HIGHLY UNORTHODOX UPDATING THING, part 2
14123
3/4
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 56320 times.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
57856 if(fixpolsvoice && tempguy.family==eePOLSV)
14124 {
14125 tempguy.step /= 2;
14126 }
14127
14128
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.homing),f))
14129 {
14130 return qe_invalid;
14131 }
14132
14133
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.grumble),f))
14134 {
14135 return qe_invalid;
14136 }
14137
14138
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.item_set),f))
14139 {
14140 return qe_invalid;
14141 }
14142
14143
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
14144 {
14145
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc1),f))
14146 {
14147 return qe_invalid;
14148 }
14149
14150
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc2),f))
14151 {
14152 return qe_invalid;
14153 }
14154
14155
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc3),f))
14156 {
14157 return qe_invalid;
14158 }
14159
14160
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc4),f))
14161 {
14162 return qe_invalid;
14163 }
14164
14165
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc5),f))
14166 {
14167 return qe_invalid;
14168 }
14169
14170
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc6),f))
14171 {
14172 return qe_invalid;
14173 }
14174
14175
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc7),f))
14176 {
14177 return qe_invalid;
14178 }
14179
14180
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc8),f))
14181 {
14182 return qe_invalid;
14183 }
14184
14185
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc9),f))
14186 {
14187 return qe_invalid;
14188 }
14189
14190
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc10),f))
14191 {
14192 return qe_invalid;
14193 }
14194 57856 }
14195 else
14196 {
14197 int16_t tempMisc;
14198
14199 if(!p_igetw(&tempMisc,f))
14200 {
14201 return qe_invalid;
14202 }
14203
14204 tempguy.misc1=tempMisc;
14205
14206 if(!p_igetw(&tempMisc,f))
14207 {
14208 return qe_invalid;
14209 }
14210
14211 tempguy.misc2=tempMisc;
14212
14213 if(!p_igetw(&tempMisc,f))
14214 {
14215 return qe_invalid;
14216 }
14217
14218 tempguy.misc3=tempMisc;
14219
14220 if(!p_igetw(&tempMisc,f))
14221 {
14222 return qe_invalid;
14223 }
14224
14225 tempguy.misc4=tempMisc;
14226
14227 if(!p_igetw(&tempMisc,f))
14228 {
14229 return qe_invalid;
14230 }
14231
14232 tempguy.misc5=tempMisc;
14233
14234 if(guyversion < 13) // April 2009 - a tiny Wizzrobe update
14235 {
14236 if(tempguy.family == eeWIZZ && !(tempguy.misc1))
14237 tempguy.misc5 = 74;
14238 }
14239
14240 if(!p_igetw(&tempMisc,f))
14241 {
14242 return qe_invalid;
14243 }
14244
14245 tempguy.misc6=tempMisc;
14246
14247 if(!p_igetw(&tempMisc,f))
14248 {
14249 return qe_invalid;
14250 }
14251
14252 tempguy.misc7=tempMisc;
14253
14254 if(!p_igetw(&tempMisc,f))
14255 {
14256 return qe_invalid;
14257 }
14258
14259 tempguy.misc8=tempMisc;
14260
14261 if(!p_igetw(&tempMisc,f))
14262 {
14263 return qe_invalid;
14264 }
14265
14266 tempguy.misc9=tempMisc;
14267
14268 if(!p_igetw(&tempMisc,f))
14269 {
14270 return qe_invalid;
14271 }
14272
14273 tempguy.misc10=tempMisc;
14274 }
14275
14276
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.bgsfx),f))
14277 {
14278 return qe_invalid;
14279 }
14280
14281
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.bosspal),f))
14282 {
14283 return qe_invalid;
14284 }
14285
14286
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.extend),f))
14287 {
14288 return qe_invalid;
14289 }
14290
14291 //! Enemy Defences
14292
14293 //If a 2.50 quest, use only the 2.5 defences.
14294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57856 times.
57856 if(guyversion >= 16 ) // November 2009 - Super Enemy Editor
14295 {
14296
2/2
✓ Branch 0 taken 1099264 times.
✓ Branch 1 taken 57856 times.
1157120 for(int32_t j=0; j<edefLAST; j++)
14297 {
14298
1/2
✓ Branch 0 taken 1099264 times.
✗ Branch 1 not taken.
1099264 if(!p_getc(&(tempguy.defense[j]),f))
14299 {
14300 return qe_invalid;
14301 }
14302 1099264 }
14303 //then copy the generic script defence to all the new script defences
14304
14305 57856 }
14306
14307
14308
14309
14310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57856 times.
57856 if(guyversion >= 18)
14311 {
14312
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&(tempguy.hitsfx),f))
14313 {
14314 return qe_invalid;
14315 }
14316
14317
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&(tempguy.deadsfx),f))
14318 {
14319 return qe_invalid;
14320 }
14321 57856 }
14322
14323
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion >= 22)
14324 {
14325
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc11),f))
14326 {
14327 return qe_invalid;
14328 }
14329
14330
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc12),f))
14331 {
14332 return qe_invalid;
14333 }
14334 57856 }
14335 else if(guyversion >= 19)
14336 {
14337 int16_t tempMisc;
14338
14339 if(!p_igetw(&tempMisc,f))
14340 {
14341 return qe_invalid;
14342 }
14343
14344 tempguy.misc11=tempMisc;
14345
14346 if(!p_igetw(&tempMisc,f))
14347 {
14348 return qe_invalid;
14349 }
14350
14351 tempguy.misc12=tempMisc;
14352 }
14353
14354 //If a 2.54 or later quest, use all of the defences.
14355
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if(guyversion > 24) // Add new guyversion conditional statement
14356 {
14357
2/2
✓ Branch 0 taken 405504 times.
✓ Branch 1 taken 18432 times.
423936 for(int32_t j=edefLAST; j<edefLAST255; j++)
14358 {
14359
1/2
✓ Branch 0 taken 405504 times.
✗ Branch 1 not taken.
405504 if(!p_getc(&(tempguy.defense[j]),f))
14360 {
14361 return qe_invalid;
14362 }
14363 405504 }
14364 18432 }
14365
14366
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if(guyversion <= 24) // Port over generic script settings from old quests in the new editor.
14367 {
14368
2/2
✓ Branch 0 taken 394240 times.
✓ Branch 1 taken 39424 times.
433664 for(int32_t j=edefSCRIPT01; j<=edefSCRIPT10; j++)
14369 {
14370 394240 tempguy.defense[j] = tempguy.defense[edefSCRIPT] ;
14371 394240 }
14372 39424 }
14373
14374 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
14375
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if(guyversion > 25)
14376 {
14377
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.txsz),f))
14378 {
14379 return qe_invalid;
14380 }
14381
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.tysz),f))
14382 {
14383 return qe_invalid;
14384 }
14385
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.hxsz),f))
14386 {
14387 return qe_invalid;
14388 }
14389
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.hysz),f))
14390 {
14391 return qe_invalid;
14392 }
14393
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.hzsz),f))
14394 {
14395 return qe_invalid;
14396 }
14397 /* Is it safe to read a fixed with getl, or do I need to typecast it? -Z
14398
14399 */
14400 18432 }
14401 //More Enemy Editor vars for 2.60
14402
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if(guyversion > 26)
14403 {
14404
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.hxofs),f))
14405 {
14406 return qe_invalid;
14407 }
14408
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.hyofs),f))
14409 {
14410 return qe_invalid;
14411 }
14412
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.xofs),f))
14413 {
14414 return qe_invalid;
14415 }
14416
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.yofs),f))
14417 {
14418 return qe_invalid;
14419 }
14420
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.zofs),f))
14421 {
14422 return qe_invalid;
14423 }
14424 18432 }
14425
14426
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if(guyversion <= 27) // Port over generic script settings from old quests in the new editor.
14427 {
14428 39424 tempguy.wpnsprite = 0;
14429 39424 }
14430
14431
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if(guyversion > 27)
14432 {
14433
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.wpnsprite),f))
14434 {
14435 return qe_invalid;
14436 }
14437 18432 }
14438
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if(guyversion <= 28) // Port over generic script settings from old quests in the new editor.
14439 {
14440 39424 tempguy.SIZEflags = 0;
14441 39424 }
14442
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if(guyversion > 28)
14443 {
14444
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.SIZEflags),f))
14445 {
14446 return qe_invalid;
14447 }
14448
14449 18432 }
14450
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if(guyversion < 30) // Port over generic script settings from old quests in the new editor.
14451 {
14452 39424 tempguy.frozentile = 0;
14453 39424 tempguy.frozencset = 0;
14454 39424 tempguy.frozenclock = 0;
14455
2/2
✓ Branch 0 taken 394240 times.
✓ Branch 1 taken 39424 times.
433664 for ( int32_t q = 0; q < 10; q++ ) tempguy.frozenmisc[q] = 0;
14456 39424 }
14457
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if(guyversion >= 30)
14458 {
14459
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.frozentile),f))
14460 {
14461 return qe_invalid;
14462 }
14463
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.frozencset),f))
14464 {
14465 return qe_invalid;
14466 }
14467
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.frozenclock),f))
14468 {
14469 return qe_invalid;
14470 }
14471
2/2
✓ Branch 0 taken 184320 times.
✓ Branch 1 taken 18432 times.
202752 for ( int32_t q = 0; q < 10; q++ ) {
14472
1/2
✓ Branch 0 taken 184320 times.
✗ Branch 1 not taken.
184320 if(!p_igetw(&(tempguy.frozenmisc[q]),f))
14473 {
14474 return qe_invalid;
14475 }
14476 184320 }
14477
14478 18432 }
14479
14480
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if(guyversion >= 34)
14481 {
14482
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetw(&(tempguy.firesfx),f))
14483 {
14484 return qe_invalid;
14485 }
14486
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc16),f))
14487 {
14488 return qe_invalid;
14489 }
14490
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc17),f))
14491 {
14492 return qe_invalid;
14493 }
14494
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc18),f))
14495 {
14496 return qe_invalid;
14497 }
14498
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc19),f))
14499 {
14500 return qe_invalid;
14501 }
14502
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc20),f))
14503 {
14504 return qe_invalid;
14505 }
14506
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc21),f))
14507 {
14508 return qe_invalid;
14509 }
14510
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc22),f))
14511 {
14512 return qe_invalid;
14513 }
14514
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc23),f))
14515 {
14516 return qe_invalid;
14517 }
14518
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc24),f))
14519 {
14520 return qe_invalid;
14521 }
14522
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc25),f))
14523 {
14524 return qe_invalid;
14525 }
14526
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc26),f))
14527 {
14528 return qe_invalid;
14529 }
14530
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc27),f))
14531 {
14532 return qe_invalid;
14533 }
14534
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc28),f))
14535 {
14536 return qe_invalid;
14537 }
14538
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc29),f))
14539 {
14540 return qe_invalid;
14541 }
14542
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc30),f))
14543 {
14544 return qe_invalid;
14545 }
14546
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc31),f))
14547 {
14548 return qe_invalid;
14549 }
14550
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc32),f))
14551 {
14552 return qe_invalid;
14553 }
14554
14555
2/2
✓ Branch 0 taken 589824 times.
✓ Branch 1 taken 18432 times.
608256 for ( int32_t q = 0; q < 32; q++ ) {
14556
1/2
✓ Branch 0 taken 589824 times.
✗ Branch 1 not taken.
589824 if(!p_igetl(&(tempguy.movement[q]),f))
14557 {
14558 return qe_invalid;
14559 }
14560 589824 }
14561
2/2
✓ Branch 0 taken 589824 times.
✓ Branch 1 taken 18432 times.
608256 for ( int32_t q = 0; q < 32; q++ ) {
14562
1/2
✓ Branch 0 taken 589824 times.
✗ Branch 1 not taken.
589824 if(!p_igetl(&(tempguy.new_weapon[q]),f))
14563 {
14564 return qe_invalid;
14565 }
14566 589824 }
14567
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetw(&(tempguy.script),f))
14568 {
14569 return qe_invalid;
14570 }
14571 //al_trace("NPC Script ID is: %d\n",tempguy.script);
14572
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 18432 times.
165888 for ( int32_t q = 0; q < 8; q++ )
14573 {
14574
1/2
✓ Branch 0 taken 147456 times.
✗ Branch 1 not taken.
147456 if(!p_igetl(&(tempguy.initD[q]),f))
14575 {
14576 return qe_invalid;
14577 }
14578 147456 }
14579
2/2
✓ Branch 0 taken 36864 times.
✓ Branch 1 taken 18432 times.
55296 for ( int32_t q = 0; q < 2; q++ )
14580 {
14581
1/2
✓ Branch 0 taken 36864 times.
✗ Branch 1 not taken.
36864 if(!p_igetl(&(tempguy.initA[q]),f))
14582 {
14583 return qe_invalid;
14584 }
14585 36864 }
14586
14587 18432 }
14588
14589
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if(guyversion >= 37)
14590 {
14591
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.editorflags),f))
14592 {
14593 return qe_invalid;
14594 }
14595 18432 }
14596
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if ( guyversion < 37 ) { tempguy.editorflags = 0; }
14597
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if(guyversion >= 38)
14598 {
14599
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc13),f))
14600 {
14601 return qe_invalid;
14602 }
14603
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc14),f))
14604 {
14605 return qe_invalid;
14606 }
14607
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc15),f))
14608 {
14609 return qe_invalid;
14610 }
14611
14612 18432 }
14613
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if ( guyversion < 38 )
14614 {
14615 39424 tempguy.misc13 = 0;
14616 39424 tempguy.misc14 = 0;
14617 39424 tempguy.misc15 = 0;
14618 39424 }
14619
14620
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if ( guyversion >= 39 )
14621 {
14622
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 18432 times.
165888 for ( int32_t q = 0; q < 8; q++ )
14623 {
14624
2/2
✓ Branch 0 taken 9584640 times.
✓ Branch 1 taken 147456 times.
9732096 for ( int32_t w = 0; w < 65; w++ )
14625 {
14626
1/2
✓ Branch 0 taken 9584640 times.
✗ Branch 1 not taken.
9584640 if(!p_getc(&(tempguy.initD_label[q][w]),f))
14627 {
14628 return qe_invalid;
14629 }
14630 9584640 }
14631
2/2
✓ Branch 0 taken 9584640 times.
✓ Branch 1 taken 147456 times.
9732096 for ( int32_t w = 0; w < 65; w++ )
14632 {
14633
1/2
✓ Branch 0 taken 9584640 times.
✗ Branch 1 not taken.
9584640 if(!p_getc(&(tempguy.weapon_initD_label[q][w]),f))
14634 {
14635 return qe_invalid;
14636 }
14637 9584640 }
14638 147456 }
14639
14640
14641 18432 }
14642
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if ( guyversion < 39 ) //apply old InitD strings to both
14643 {
14644
2/2
✓ Branch 0 taken 315392 times.
✓ Branch 1 taken 39424 times.
354816 for ( int32_t q = 0; q < 8; q++ )
14645 {
14646 315392 sprintf(tempguy.initD_label[q],"InitD[%d]",q);
14647 315392 sprintf(tempguy.weapon_initD_label[q],"InitD[%d]",q);
14648 315392 }
14649 39424 }
14650
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if ( guyversion >= 40 )
14651 {
14652
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetw(&(tempguy.weaponscript),f))
14653 {
14654 return qe_invalid;
14655 }
14656 18432 }
14657
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if ( guyversion < 40 )
14658 {
14659 39424 tempguy.weaponscript = 0;
14660 39424 }
14661 //eweapon script InitD
14662
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if ( guyversion >= 41 )
14663 {
14664
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 18432 times.
165888 for ( int32_t q = 0; q < 8; q++ )
14665 {
14666
1/2
✓ Branch 0 taken 147456 times.
✗ Branch 1 not taken.
147456 if(!p_igetl(&(tempguy.weap_initiald[q]),f))
14667 {
14668 return qe_invalid;
14669 }
14670 147456 }
14671
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if ( guy_cversion < 4 )
14672 {
14673 if ( tempguy.family == eeKEESE )
14674 {
14675
14676 if ( !tempguy.misc1 )
14677 {
14678 tempguy.misc16 = 120;
14679 tempguy.misc17 = 16;
14680
14681 }
14682 }
14683 if ( tempguy.family == eePEAHAT )
14684 {
14685 tempguy.misc16 = 80;
14686 tempguy.misc17 = 16;
14687 }
14688
14689 if ( tempguy.family == eeGHINI )
14690 {
14691 tempguy.misc16 = 120;
14692 tempguy.misc17 = 10;
14693 }
14694
14695 }
14696 18432 }
14697
14698
14699
14700 //default weapon sprites (quest version < 2.54)
14701 //port over old defaults -Z
14702
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if(guyversion < 32)
14703 {
14704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39424 times.
39424 if ( tempguy.wpnsprite <= 0 )
14705 {
14706
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1303 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32842 times.
✓ Branch 4 taken 302 times.
✓ Branch 5 taken 314 times.
✓ Branch 6 taken 931 times.
✓ Branch 7 taken 493 times.
✓ Branch 8 taken 912 times.
✓ Branch 9 taken 80 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 137 times.
✓ Branch 12 taken 19 times.
✓ Branch 13 taken 363 times.
✓ Branch 14 taken 759 times.
✓ Branch 15 taken 106 times.
✓ Branch 16 taken 80 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 765 times.
39424 switch(tempguy.weapon)
14707 {
14708 case wNone:
14709 32842 tempguy.wpnsprite = 0; break;
14710
14711 case wSword:
14712 case wBeam:
14713 case wBrang:
14714 case wBomb:
14715 case wSBomb:
14716 case wLitBomb:
14717 case wLitSBomb:
14718 case wArrow:
14719 case wFire:
14720 case wWhistle:
14721 case wBait:
14722 case wWand:
14723 case wMagic:
14724 case wCatching:
14725 case wWind:
14726 case wRefMagic:
14727 case wRefFireball:
14728 case wRefRock:
14729 case wHammer:
14730 case wHookshot:
14731 case wHSHandle:
14732 case wHSChain:
14733 case wSSparkle:
14734 case wFSparkle:
14735 case wSmack:
14736 case wPhantom:
14737 case wCByrna:
14738 case wRefBeam:
14739 case wStomp:
14740 case lwMax:
14741 case wScript1:
14742 case wScript2:
14743 case wScript3:
14744 case wScript4:
14745 case wScript5:
14746 case wScript6:
14747 case wScript7:
14748 case wScript8:
14749 case wScript9:
14750 case wScript10:
14751 case wIce:
14752 //Cannot use any of these weapons yet.
14753 tempguy.wpnsprite = -1;
14754 break;
14755
14756 case wEnemyWeapons:
14757 1303 case ewFireball: tempguy.wpnsprite = 17; break;
14758
14759 302 case ewArrow: tempguy.wpnsprite = 19; break;
14760 314 case ewBrang: tempguy.wpnsprite = 4; break;
14761 931 case ewSword: tempguy.wpnsprite = 20; break;
14762 493 case ewRock: tempguy.wpnsprite = 18; break;
14763 912 case ewMagic: tempguy.wpnsprite = 21; break;
14764 80 case ewBomb: tempguy.wpnsprite = 78; break;
14765 18 case ewSBomb: tempguy.wpnsprite = 79; break;
14766 137 case ewLitBomb: tempguy.wpnsprite = 76; break;
14767 19 case ewLitSBomb: tempguy.wpnsprite = 77; break;
14768 363 case ewFireTrail: tempguy.wpnsprite = 80; break;
14769 759 case ewFlame: tempguy.wpnsprite = 35; break;
14770 106 case ewWind: tempguy.wpnsprite = 36; break;
14771 80 case ewFlame2: tempguy.wpnsprite = 81; break;
14772 case ewFlame2Trail: tempguy.wpnsprite = 82; break;
14773 case ewIce: tempguy.wpnsprite = 83; break;
14774 765 case ewFireball2: tempguy.wpnsprite = 17; break; //fireball (rising)
14775
14776
14777 default: break; //No assign.
14778 }
14779 39424 }
14780 39424 }
14781
14782 //default weapon fire sound (quest version < 2.54)
14783 //port over old defaults and zero new data. -Z
14784
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if(guyversion < 34)
14785 {
14786
2/2
✓ Branch 0 taken 1261568 times.
✓ Branch 1 taken 39424 times.
1300992 for ( int32_t q = 0; q < 32; q++ )
14787 {
14788 1261568 tempguy.movement[q] = 0;
14789 1261568 tempguy.new_weapon[q] = 0;
14790
14791 1261568 }
14792
14793 //NPC Script attributes.
14794 39424 tempguy.script = 0; //No scripted enemies existed. -Z
14795
2/2
✓ Branch 0 taken 315392 times.
✓ Branch 1 taken 39424 times.
354816 for ( int32_t q = 0; q < 8; q++ ) tempguy.initD[q] = 0; //Script Data
14796
2/2
✓ Branch 0 taken 78848 times.
✓ Branch 1 taken 39424 times.
118272 for ( int32_t q = 0; q < 2; q++ ) tempguy.initA[q] = 0; //Script Data
14797
14798 39424 tempguy.misc16 = 0;
14799 39424 tempguy.misc17 = 0;
14800 39424 tempguy.misc18 = 0;
14801 39424 tempguy.misc19 = 0;
14802 39424 tempguy.misc20 = 0;
14803 39424 tempguy.misc21 = 0;
14804 39424 tempguy.misc22 = 0;
14805 39424 tempguy.misc23 = 0;
14806 39424 tempguy.misc24 = 0;
14807 39424 tempguy.misc25 = 0;
14808 39424 tempguy.misc26 = 0;
14809 39424 tempguy.misc27 = 0;
14810 39424 tempguy.misc28 = 0;
14811 39424 tempguy.misc29 = 0;
14812 39424 tempguy.misc30 = 0;
14813 39424 tempguy.misc31 = 0;
14814 39424 tempguy.misc32 = 0;
14815
14816 //old default sounds
14817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39424 times.
39424 if ( tempguy.firesfx <= 0 )
14818 {
14819
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1303 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32842 times.
✓ Branch 4 taken 302 times.
✓ Branch 5 taken 314 times.
✓ Branch 6 taken 931 times.
✓ Branch 7 taken 493 times.
✓ Branch 8 taken 912 times.
✓ Branch 9 taken 80 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 137 times.
✓ Branch 12 taken 19 times.
✓ Branch 13 taken 363 times.
✓ Branch 14 taken 759 times.
✓ Branch 15 taken 106 times.
✓ Branch 16 taken 80 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 765 times.
39424 switch(tempguy.weapon)
14820 {
14821 case wNone:
14822 32842 tempguy.firesfx = 0; break;
14823
14824 case wSword:
14825 case wBeam:
14826 case wBrang:
14827 case wBomb:
14828 case wSBomb:
14829 case wLitBomb:
14830 case wLitSBomb:
14831 case wArrow:
14832 case wFire:
14833 case wWhistle:
14834 case wBait:
14835 case wWand:
14836 case wMagic:
14837 case wCatching:
14838 case wWind:
14839 case wRefMagic:
14840 case wRefFireball:
14841 case wRefRock:
14842 case wHammer:
14843 case wHookshot:
14844 case wHSHandle:
14845 case wHSChain:
14846 case wSSparkle:
14847 case wFSparkle:
14848 case wSmack:
14849 case wPhantom:
14850 case wCByrna:
14851 case wRefBeam:
14852 case wStomp:
14853 case lwMax:
14854 case wScript1:
14855 case wScript2:
14856 case wScript3:
14857 case wScript4:
14858 case wScript5:
14859 case wScript6:
14860 case wScript7:
14861 case wScript8:
14862 case wScript9:
14863 case wScript10:
14864 case wIce:
14865 //Cannot use any of these weapons yet.
14866 tempguy.firesfx = -1;
14867 break;
14868
14869 case wEnemyWeapons:
14870 1303 case ewFireball: tempguy.firesfx = 40; break;
14871
14872 302 case ewArrow: tempguy.firesfx = 1; break; //Ghost.zh has 0?
14873 314 case ewBrang: tempguy.firesfx = 4; break; //Ghost.zh has 0?
14874 931 case ewSword: tempguy.firesfx = 20; break; //Ghost.zh has 0?
14875 493 case ewRock: tempguy.firesfx = 51; break;
14876 912 case ewMagic: tempguy.firesfx = 32; break;
14877 80 case ewBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14878 18 case ewSBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14879 137 case ewLitBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14880 19 case ewLitSBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14881 363 case ewFireTrail: tempguy.firesfx = 13; break;
14882 759 case ewFlame: tempguy.firesfx = 13; break;
14883 106 case ewWind: tempguy.firesfx = 32; break;
14884 80 case ewFlame2: tempguy.firesfx = 13; break;
14885 case ewFlame2Trail: tempguy.firesfx = 13; break;
14886 case ewIce: tempguy.firesfx = 44; break;
14887 765 case ewFireball2: tempguy.firesfx = 40; break; //fireball (rising)
14888
14889 //what about special attacks (e.g. summoning == 56)
14890 default: break; //No assign.
14891 }
14892 39424 }
14893 39424 }
14894
14895 //Port hardcoded hit sound to the enemy hitsfx defaults for older quests.
14896
4/6
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
✓ Branch 2 taken 18432 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 18432 times.
57856 if(Header->zelda_version <= 0x250 || ( Header->zelda_version > 0x250 && guyversion < 35 ))
14897 {
14898
2/2
✓ Branch 0 taken 3549 times.
✓ Branch 1 taken 35875 times.
39424 if ( tempguy.hitsfx == 0 ) tempguy.hitsfx = 11;
14899 39424 }
14900 //Keese and bat halt rates.
14901
3/4
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39424 times.
57856 if ( guyversion < 42 && guy_cversion < 4 )
14902 {
14903
14904
2/2
✓ Branch 0 taken 38895 times.
✓ Branch 1 taken 529 times.
39424 if ( tempguy.family == eeKEESE )
14905 {
14906
14907
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 326 times.
529 if ( !tempguy.misc1 )
14908 {
14909 326 tempguy.misc16 = 120;
14910 326 tempguy.misc17 = 16;
14911
14912 326 }
14913 529 }
14914
2/2
✓ Branch 0 taken 39257 times.
✓ Branch 1 taken 167 times.
39424 if ( tempguy.family == eePEAHAT )
14915 {
14916 167 tempguy.misc16 = 80;
14917 167 tempguy.misc17 = 16;
14918 167 }
14919
2/2
✓ Branch 0 taken 39347 times.
✓ Branch 1 taken 77 times.
39424 if ( tempguy.family == eeGHINI )
14920 {
14921 77 tempguy.misc16 = 120;
14922 77 tempguy.misc17 = 10;
14923 77 }
14924
14925
14926 39424 }
14927
14928
14929 //miscellaneous other corrections
14930 //fix the mirror wizzrobe -DD
14931
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 7)
14932 {
14933 if(i == eMWIZ)
14934 {
14935 tempguy.misc2 = 0;
14936 tempguy.misc4 = 1;
14937 }
14938 }
14939
14940
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 8)
14941 {
14942 if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14943 {
14944 // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
14945 tempguy.misc5 = 4; //neck length in segments
14946 tempguy.misc6 = 8; //neck offset from first body tile
14947 tempguy.misc7 = 40; //offset for each subsequent neck tile from the first neck tile
14948 tempguy.misc8 = 168; //head offset from first body tile
14949 tempguy.misc9 = 228; //flying head offset from first body tile
14950
14951 if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14952 {
14953 tempguy.misc6 += 10; //neck offset from first body tile
14954 tempguy.misc8 -= 12; //head offset from first body tile
14955 }
14956 }
14957 }
14958
14959
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 10) // December 2007 - Dodongo CSet fix
14960 {
14961 if(get_bit(deprecated_rules,46) && tempguy.family==eeDONGO && tempguy.misc1==0)
14962 tempguy.bosspal = spDIG;
14963 }
14964
14965
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 11) // December 2007 - Spinning Tile fix
14966 {
14967 if(tempguy.family==eeSPINTILE)
14968 {
14969 tempguy.flags |= guy_superman;
14970 tempguy.item_set = 0; // Don't drop items
14971 tempguy.step = 300;
14972 }
14973 }
14974
14975
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
14976 {
14977 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
14978 {
14979 if(tempguy.family==eeROPE)
14980 {
14981 tempguy.flags2 &= ~guy_flashing;
14982 }
14983 }
14984
14985 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
14986 {
14987 if(tempguy.family==eeBUBBLE)
14988 {
14989 tempguy.flags2 &= ~guy_flashing;
14990 }
14991 }
14992
14993 if((tempguy.family==eeGHINI)&&(tempguy.misc1))
14994 {
14995 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
14996 {
14997 tempguy.flags2 |= guy_blinking;
14998 }
14999
15000 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
15001 {
15002 tempguy.flags2 |= guy_transparent;
15003 }
15004 }
15005 }
15006
15007
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
15008 {
15009 if(i==gFIRE)
15010 {
15011 tempguy.e_anim = aFLIP;
15012 tempguy.e_frate = 24;
15013 }
15014
15015 if(i==gFAIRY)
15016 {
15017 tempguy.e_anim = a2FRM;
15018 tempguy.e_frate = 16;
15019 }
15020 }
15021
15022
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 16) // November 2009 - Super Enemy Editor part 1
15023 {
15024 if(i==0) Z_message("Updating guys to version 16...\n");
15025
15026 update_guy_1(&tempguy);
15027
15028 if(i==eMPOLSV)
15029 {
15030 tempguy.defense[edefARROW] = edCHINK;
15031 tempguy.defense[edefMAGIC] = ed1HKO;
15032 tempguy.defense[edefREFMAGIC] = ed1HKO;
15033 }
15034 }
15035
15036
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 17) // December 2009
15037 {
15038 if(tempguy.family==eePROJECTILE)
15039 {
15040 tempguy.misc1 = 0;
15041 }
15042 }
15043
15044
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 18) // January 2010
15045 {
15046 bool boss = (tempguy.family == eeAQUA || tempguy.family==eeDONGO || tempguy.family == eeMANHAN || tempguy.family == eeGHOMA || tempguy.family==eeDIG
15047 || tempguy.family == eeGLEEOK || tempguy.family==eePATRA || tempguy.family == eeGANON || tempguy.family==eeMOLD);
15048
15049 tempguy.hitsfx = (boss && tempguy.family != eeMOLD && tempguy.family != eeDONGO && tempguy.family != eeDIG) ? WAV_GASP : 0;
15050 tempguy.deadsfx = (boss && (tempguy.family != eeDIG || tempguy.misc10 == 0)) ? WAV_GASP : WAV_EDEAD;
15051
15052 if(tempguy.family == eeAQUA)
15053 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
15054 else if(tempguy.family == eeMANHAN)
15055 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
15056 else if(tempguy.family==eePATRA)
15057 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15058 else if(tempguy.family==eeGHOMA)
15059 {
15060 for(int32_t j=0; j<edefLAST; j++)
15061 tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
15062
15063 tempguy.defense[edefARROW] = ((tempguy.misc1==3) ? edCHINKL8 : (tempguy.misc1==2) ? edCHINKL4 : 0);
15064
15065 if(tempguy.misc1==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
15066
15067 tempguy.misc1--;
15068 }
15069 else if(tempguy.family == eeGLEEOK)
15070 {
15071 for(int32_t j=0; j<edefLAST; j++)
15072 tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15073
15074 if(tempguy.misc3==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
15075 }
15076 else if(tempguy.family == eeARMOS)
15077 {
15078 tempguy.family=eeWALK;
15079 tempguy.hrate = 0;
15080 tempguy.misc10 = tempguy.misc1;
15081 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 = tempguy.misc7 = tempguy.misc8 = 0;
15082 tempguy.misc9 = e9tARMOS;
15083 }
15084 else if(tempguy.family == eeGHINI && !tempguy.misc1)
15085 {
15086 tempguy.family=eeWALK;
15087 tempguy.hrate = 0;
15088 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 =
15089 tempguy.misc7 = tempguy.misc8 = tempguy.misc9 = tempguy.misc10 = 0;
15090 }
15091
15092 // Spawn animation flags
15093 if(tempguy.family == eeWALK && (tempguy.flags2&cmbflag_armos || tempguy.flags2&cmbflag_ghini))
15094 tempguy.flags |= guy_fadeflicker;
15095 else
15096 tempguy.flags &= 0x0F00000F; // Get rid of the unused flags!
15097 }
15098
15099
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 20) // April 2010
15100 {
15101 if(tempguy.family == eeTRAP)
15102 {
15103 tempguy.misc2 = tempguy.misc10;
15104
15105 if(tempguy.misc10>=1)
15106 {
15107 tempguy.misc1++;
15108 }
15109
15110 tempguy.misc10 = 0;
15111 }
15112
15113 // Bomb Blast fix
15114 if(tempguy.weapon==ewBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
15115 tempguy.weapon = ewLitBomb;
15116 else if(tempguy.weapon==ewSBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
15117 tempguy.weapon = ewLitSBomb;
15118 }
15119
15120
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 21) // September 2011
15121 {
15122 if(tempguy.family == eeKEESE || tempguy.family == eeKEESETRIB)
15123 {
15124 if(tempguy.family == eeKEESETRIB)
15125 {
15126 tempguy.family = eeKEESE;
15127 tempguy.misc2 = e2tKEESETRIB;
15128 tempguy.misc1 = 0;
15129 }
15130
15131 tempguy.rate = 2;
15132 tempguy.hrate = 8;
15133 tempguy.homing = 0;
15134 tempguy.step= (tempguy.family == eeKEESE && tempguy.misc1 ? 100:62);
15135 }
15136 else if(tempguy.family == eePEAHAT || tempguy.family==eePATRA)
15137 {
15138 if(tempguy.family == eePEAHAT)
15139 {
15140 tempguy.rate = 4;
15141 tempguy.step = 62;
15142 }
15143 else
15144 tempguy.step = 25;
15145
15146 tempguy.hrate = 8;
15147 tempguy.homing = 0;
15148 }
15149 else if(tempguy.family == eeDIG || tempguy.family == eeMANHAN)
15150 {
15151 if(tempguy.family == eeMANHAN)
15152 tempguy.step=50;
15153
15154 tempguy.hrate = 16;
15155 tempguy.homing = 0;
15156 }
15157 else if(tempguy.family == eeGLEEOK)
15158 {
15159 tempguy.rate = 2;
15160 tempguy.homing = 0;
15161 tempguy.hrate = 9;
15162 tempguy.step=89;
15163 }
15164 else if(tempguy.family == eeGHINI)
15165 {
15166 tempguy.rate = 4;
15167 tempguy.hrate = 12;
15168 tempguy.step=62;
15169 tempguy.homing = 0;
15170 }
15171
15172 // Bigdig random rate fix
15173 if(tempguy.family==eeDIG && tempguy.misc10==1)
15174 {
15175 tempguy.rate = 2;
15176 }
15177 }
15178
15179
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 24) // November 2012
15180 {
15181 if(tempguy.family==eeLANM)
15182 tempguy.misc3 = 1;
15183 else if(tempguy.family==eeMOLD)
15184 tempguy.misc2 = 0;
15185 }
15186
15187
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if(guyversion < 33) //Whistle defence did not exist before this version of 2.54. -Z
15188 {
15189
2/2
✓ Branch 0 taken 660 times.
✓ Branch 1 taken 38764 times.
39424 if(tempguy.family!=eeDIG)
15190 {
15191 38764 tempguy.defense[edefWhistle] = edIGNORE; //Might need to be ignore, universally.
15192 38764 }
15193
15194 39424 }
15195 // does not seem to solve the issue!
15196
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if ( Header->zelda_version <= 0x210 )
15197 {
15198 al_trace("Detected version %d for dodongo patch.\n",Header->zelda_version);
15199 if ( tempguy.family == eeDONGO )
15200 {
15201 tempguy.deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
15202 }
15203 }
15204
15205
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if(guyversion >= 42)
15206 {
15207
2/2
✓ Branch 0 taken 17408 times.
✓ Branch 1 taken 1024 times.
18432 if(guyversion >= 47)
15208 {
15209
1/2
✓ Branch 0 taken 17408 times.
✗ Branch 1 not taken.
17408 if(!p_igetl(&(tempguy.moveflags),f))
15210 {
15211 return qe_invalid;
15212 }
15213 17408 }
15214 else
15215 {
15216 byte fl;
15217
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&fl,f))
15218 {
15219 return qe_invalid;
15220 }
15221 1024 tempguy.moveflags = fl;
15222 }
15223 18432 }
15224 else
15225 {
15226
7/8
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 30899 times.
✓ Branch 2 taken 1202 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 518 times.
✓ Branch 5 taken 278 times.
✓ Branch 6 taken 241 times.
✓ Branch 7 taken 5840 times.
39424 switch(tempguy.family)
15227 {
15228 //No gravity; floats over pits
15229 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15230 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15231 //Special (bosses, etc)
15232 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15233 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15234 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15235 30899 tempguy.moveflags = FLAG_CAN_PITWALK;
15236 30899 break;
15237 //No gravity, but falls in pits
15238 case eeLEV:
15239 518 tempguy.moveflags = FLAG_CAN_PITFALL;
15240 518 break;
15241 //Bosses that respect pits
15242 case eeDONGO:
15243 278 tempguy.moveflags = FLAG_OBEYS_GRAV;
15244 278 break;
15245 case eeLANM:
15246 241 tempguy.moveflags = 0;
15247 241 break;
15248 //Gravity, floats over pits
15249 case eeWIZZ: case eeWALLM: case eeGHINI:
15250 1202 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITWALK;
15251 1202 break;
15252 //Gravity and falls in pits
15253 case eeWALK:
15254
4/4
✓ Branch 0 taken 5519 times.
✓ Branch 1 taken 321 times.
✓ Branch 2 taken 280 times.
✓ Branch 3 taken 5239 times.
5840 if (tempguy.misc9==e9tPOLSVOICE||tempguy.misc9==e9tVIRE)
15255 601 break;
15256 [[fallthrough]];
15257 case eeOTHER:
15258 case eeSCRIPT01: case eeSCRIPT02: case eeSCRIPT03: case eeSCRIPT04: case eeSCRIPT05:
15259 case eeSCRIPT06: case eeSCRIPT07: case eeSCRIPT08: case eeSCRIPT09: case eeSCRIPT10:
15260 case eeSCRIPT11: case eeSCRIPT12: case eeSCRIPT13: case eeSCRIPT14: case eeSCRIPT15:
15261 case eeSCRIPT16: case eeSCRIPT17: case eeSCRIPT18: case eeSCRIPT19: case eeSCRIPT20:
15262 case eeFFRIENDLY01: case eeFFRIENDLY02: case eeFFRIENDLY03: case eeFFRIENDLY04: case eeFFRIENDLY05:
15263 case eeFFRIENDLY06: case eeFFRIENDLY07: case eeFFRIENDLY08: case eeFFRIENDLY09: case eeFFRIENDLY10:
15264 5685 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITFALL;
15265 5685 }
15266 }
15267
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if(guyversion < 43)
15268 {
15269
2/2
✓ Branch 0 taken 32101 times.
✓ Branch 1 taken 7323 times.
39424 switch(tempguy.family)
15270 {
15271 //No gravity; floats over pits
15272 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15273 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15274 //Special (bosses, etc)
15275 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15276 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15277 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15278 case eeWIZZ: case eeWALLM: case eeGHINI:
15279 //Gravity, floats over pits
15280 32101 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15281 32101 break;
15282 }
15283 39424 }
15284
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if (guyversion < 44)
15285 {
15286
2/2
✓ Branch 0 taken 39054 times.
✓ Branch 1 taken 370 times.
39424 if ( tempguy.family == eeGHOMA )
15287 {
15288 370 tempguy.flags |= guy_fadeinstant;
15289 370 }
15290 39424 }
15291
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if (guyversion > 44)
15292 {
15293
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_getc(&(tempguy.spr_shadow),f))
15294 {
15295 return qe_invalid;
15296 }
15297
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_getc(&(tempguy.spr_death),f))
15298 {
15299 return qe_invalid;
15300 }
15301
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_getc(&(tempguy.spr_spawn),f))
15302 {
15303 return qe_invalid;
15304 }
15305 18432 }
15306 else
15307 {
15308
2/2
✓ Branch 0 taken 39271 times.
✓ Branch 1 taken 153 times.
39424 tempguy.spr_shadow = (tempguy.family==eeROCK && tempguy.misc10==1) ? iwLargeShadow : iwShadow;
15309 39424 tempguy.spr_death = iwDeath;
15310 39424 tempguy.spr_spawn = iwSpawn;
15311 }
15312
15313
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if(guyversion < 46)
15314 {
15315
4/4
✓ Branch 0 taken 5840 times.
✓ Branch 1 taken 33584 times.
✓ Branch 2 taken 5519 times.
✓ Branch 3 taken 321 times.
39424 if(tempguy.family == eeWALK && tempguy.misc9 == e9tPOLSVOICE)
15316 {
15317 321 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15318 321 }
15319 39424 }
15320
15321 57856 guysbuf[i] = tempguy;
15322 57856 }
15323 113 }
15324
15325 113 return 0;
15326 129 }
15327
15328 void update_guy_1(guydata *tempguy) // November 2009
15329 {
15330 bool doesntcount = false;
15331 tempguy->flags &= ~weak_arrow; // Formerly 'weak to arrow' which wasn't implemented
15332
15333 switch(tempguy->family)
15334 {
15335 case 1: //eeWALK
15336 switch(tempguy->misc10)
15337 {
15338 case 0: //Stalfos
15339 if(tempguy->misc1==1) // Fires four projectiles at once
15340 tempguy->misc1=4;
15341
15342 break;
15343
15344 case 1: //Darknut
15345 goto darknuts;
15346 break;
15347 }
15348
15349 tempguy->misc10 = 0;
15350 break;
15351
15352 case 2: //eeSHOOT
15353 tempguy->family = eeWALK;
15354
15355 switch(tempguy->misc10)
15356 {
15357 case 0: //Octorok
15358 if(tempguy->misc1==1||tempguy->misc1==2)
15359 {
15360 tempguy->misc1=e1tFIREOCTO;
15361 tempguy->misc2=e2tFIREOCTO;
15362 }
15363 else tempguy->misc1 = 0;
15364
15365 tempguy->misc6=tempguy->misc4;
15366 tempguy->misc4=tempguy->misc3;
15367 tempguy->misc3=0;
15368 break;
15369
15370 case 1: // Moblin
15371 tempguy->misc1 = 0;
15372 break;
15373
15374 case 2: //Lynel
15375 tempguy->misc6=tempguy->misc1+1;
15376 tempguy->misc1=0;
15377 break;
15378
15379 case 3: //Stalfos 2
15380 if(tempguy->misc1==1) // Fires four projectiles at once
15381 tempguy->misc1=e1t4SHOTS;
15382 else tempguy->misc1 = 0;
15383
15384 break;
15385
15386 case 4: //Darknut 5
15387 darknuts:
15388 tempguy->defense[edefFIRE] = edIGNORE;
15389 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15390 tempguy->defense[edefHOOKSHOT] = 0;
15391 tempguy->defense[edefARROW] = tempguy->defense[edefBYRNA] = tempguy->defense[edefREFROCK] =
15392 tempguy->defense[edefMAGIC] = tempguy->defense[edefSTOMP] = edCHINK;
15393
15394 if(tempguy->misc1==1)
15395 tempguy->misc1=2;
15396 else if(tempguy->misc1==2)
15397 {
15398 tempguy->misc4=tempguy->misc3;
15399 tempguy->misc3=tempguy->misc2;
15400 tempguy->misc2=e2tSPLIT;
15401 tempguy->misc1 = 0;
15402 }
15403 else tempguy->misc1 = 0;
15404
15405 tempguy->flags |= inv_front;
15406
15407 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
15408 tempguy->flags |= guy_bkshield;
15409
15410 break;
15411 }
15412
15413 tempguy->misc10 = 0;
15414 break;
15415
15416 /*
15417 case 9: //eeARMOS
15418 tempguy->family = eeWALK;
15419 break;
15420 */
15421 case 11: //eeGEL
15422 case 33: //eeGELTRIB
15423 if(tempguy->family==33)
15424 {
15425 tempguy->misc4 = 1;
15426
15427 if(get_bit(deprecated_rules, qr_OLDTRIBBLES_DEP)) //Old Tribbles
15428 tempguy->misc3 = tempguy->misc2;
15429
15430 tempguy->misc2 = e2tTRIBBLE;
15431 }
15432 else
15433 {
15434 tempguy->misc4 = 0;
15435 tempguy->misc3 = 0;
15436 tempguy->misc2 = 0;
15437 }
15438
15439 tempguy->family = eeWALK;
15440
15441 if(tempguy->misc1)
15442 {
15443 tempguy->misc1=1;
15444 tempguy->weapon = ewFireTrail;
15445 }
15446
15447 break;
15448
15449 case 34: //eeZOLTRIB
15450 case 12: //eeZOL
15451 tempguy->misc4=tempguy->misc3;
15452 tempguy->misc3=tempguy->misc2;
15453 tempguy->family = eeWALK;
15454 tempguy->misc2=e2tSPLITHIT;
15455
15456 if(tempguy->misc1)
15457 {
15458 tempguy->misc1=1;
15459 tempguy->weapon = ewFireTrail;
15460 }
15461
15462 break;
15463
15464 case 13: //eeROPE
15465 tempguy->family = eeWALK;
15466 tempguy->misc9 = e9tROPE;
15467
15468 if(tempguy->misc1)
15469 {
15470 tempguy->misc4 = tempguy->misc3;
15471 tempguy->misc3 = tempguy->misc2;
15472 tempguy->misc2 = e2tBOMBCHU;
15473 }
15474
15475 tempguy->misc1 = 0;
15476 break;
15477
15478 case 14: //eeGORIYA
15479 tempguy->family = eeWALK;
15480
15481 if(tempguy->misc1!=2) tempguy->misc1 = 0;
15482
15483 break;
15484
15485 case 17: //eeBUBBLE
15486 tempguy->family = eeWALK;
15487 tempguy->misc8 = tempguy->misc2;
15488 tempguy->misc7 = tempguy->misc1 + 1;
15489 tempguy->misc1 = tempguy->misc2 = 0;
15490
15491 //fallthrogh
15492 case eeTRAP:
15493 case eeROCK:
15494 doesntcount = true;
15495 break;
15496
15497 case 35: //eeVIRETRIB
15498 case 18: //eeVIRE
15499 tempguy->family = eeWALK;
15500 tempguy->misc4=tempguy->misc3;
15501 tempguy->misc3=tempguy->misc2;
15502 tempguy->misc2=e2tSPLITHIT;
15503 tempguy->misc9=e9tVIRE;
15504 break;
15505
15506 case 19: //eeLIKE
15507 tempguy->family = eeWALK;
15508 tempguy->misc7 = e7tEATITEMS;
15509 tempguy->misc8=95;
15510 break;
15511
15512 case 20: //eePOLSV
15513 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15514 tempguy->defense[edefBOMB] = tempguy->defense[edefSBOMB] = tempguy->defense[edefFIRE] = edIGNORE;
15515 tempguy->defense[edefMAGIC] = tempguy->defense[edefBYRNA] = edCHINK;
15516 tempguy->defense[edefARROW] = ed1HKO;
15517 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15518 tempguy->family = eeWALK;
15519 tempguy->misc9 = e9tPOLSVOICE;
15520 tempguy->rate = 4;
15521 tempguy->homing = 32;
15522 tempguy->hrate = 10;
15523 tempguy->grumble = 0;
15524 break;
15525
15526 case eeWIZZ:
15527 if(tempguy->misc4)
15528 {
15529 for(int32_t i=0; i < edefLAST; i++)
15530 tempguy->defense[i] = (i != edefREFBEAM && i != edefREFMAGIC && i != edefQUAKE) ? edIGNORE : 0;
15531 }
15532 else
15533 {
15534 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15535 tempguy->defense[edefMAGIC] = edCHINK;
15536 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15537 tempguy->defense[edefARROW] = tempguy->defense[edefFIRE] =
15538 tempguy->defense[edefWAND] = tempguy->defense[edefBYRNA] = edIGNORE;
15539 }
15540
15541 break;
15542
15543 case eePEAHAT:
15544 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15545
15546 if(!(tempguy->flags & guy_bhit))
15547 tempguy->defense[edefBRANG] = edSTUNONLY;
15548
15549 break;
15550
15551 case eeLEV:
15552 tempguy->defense[edefSTOMP] = edCHINK;
15553 break;
15554 }
15555
15556 // Old flags
15557 if(tempguy->flags & guy_superman)
15558 {
15559 for(int32_t i = 0; i < edefLAST; i++)
15560 if(!(i==edefSBOMB && (tempguy->flags & guy_sbombonly)))
15561 tempguy->defense[i] = (i==edefBRANG && tempguy->defense[i] != edIGNORE
15562 && tempguy->family != eeROCK && tempguy->family != eeTRAP
15563 && tempguy->family != eePROJECTILE) ? edSTUNORIGNORE : edIGNORE;
15564 }
15565
15566 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15567
15568 if(doesntcount)
15569 tempguy->flags |= (guy_doesntcount);
15570 }
15571
15572
15573 247176 int32_t readmapscreen_old(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, zcmap *temp_map, word version)
15574 {
15575 byte tempbyte, padding;
15576 int32_t extras, secretcombos;
15577 //al_trace("readmapscreen Header->zelda_version: %x\n",Header->zelda_version);
15578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->valid),f))
15579 {
15580 return qe_invalid;
15581 }
15582
15583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->guy),f))
15584 return qe_invalid;
15585 247176 temp_mapscr->guytile = -1; //signal to use default guy values
15586
2/2
✓ Branch 0 taken 246700 times.
✓ Branch 1 taken 476 times.
247176 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
15587
4/4
✓ Branch 0 taken 476 times.
✓ Branch 1 taken 246700 times.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 453 times.
247176 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
15588
15589
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<146)))
15590 {
15591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
6864 if(!p_getc(&tempbyte,f))
15592 {
15593 return qe_invalid;
15594 }
15595
15596 6864 temp_mapscr->str=tempbyte;
15597 6864 }
15598 else
15599 {
15600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
240312 if(!p_igetw(&(temp_mapscr->str),f))
15601 {
15602 return qe_invalid;
15603 }
15604 }
15605
15606
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->room),f))
15607 {
15608 return qe_invalid;
15609 }
15610
15611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->item),f))
15612 {
15613 return qe_invalid;
15614 }
15615
15616
3/6
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 153408 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if(Header->zelda_version < 0x211 || (Header->zelda_version == 0x211 && Header->build < 14))
15617 {
15618 93768 temp_mapscr->hasitem = (temp_mapscr->item != 0) ? 1 : 0;
15619 93768 }
15620 else
15621 {
15622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->hasitem),f))
15623 return qe_invalid;
15624 }
15625
15626
2/4
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
247176 if((Header->zelda_version < 0x192)||
15627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
240312 ((Header->zelda_version == 0x192)&&(Header->build<154)))
15628 {
15629
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&tempbyte,f))
15630 {
15631 return qe_invalid;
15632 }
15633 6864 }
15634
15635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->tilewarptype[0]),f))
15636 {
15637 return qe_invalid;
15638 }
15639
15640
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
247176 if(Header->zelda_version < 0x193)
15641 {
15642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
6864 if(!p_getc(&tempbyte,f))
15643 {
15644 return qe_invalid;
15645 }
15646 6864 }
15647
15648
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15649 {
15650
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15651 {
15652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
15653 {
15654 return qe_invalid;
15655 }
15656 460224 }
15657 153408 }
15658 else
15659 {
15660 93768 temp_mapscr->tilewarptype[1]=0;
15661 93768 temp_mapscr->tilewarptype[2]=0;
15662 93768 temp_mapscr->tilewarptype[3]=0;
15663 }
15664
15665
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15666 {
15667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
240312 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
15668 {
15669 return qe_invalid;
15670 }
15671 240312 }
15672
15673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->warpreturnx[0]),f))
15674 {
15675 return qe_invalid;
15676 }
15677
15678 247176 temp_mapscr->warpreturnx[1]=0;
15679 247176 temp_mapscr->warpreturnx[2]=0;
15680 247176 temp_mapscr->warpreturnx[3]=0;
15681
15682
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15683 {
15684
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15685 {
15686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
15687 {
15688 return qe_invalid;
15689 }
15690 460224 }
15691 153408 }
15692
15693
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->warpreturny[0]),f))
15694 {
15695 return qe_invalid;
15696 }
15697
15698 247176 temp_mapscr->warpreturny[1]=0;
15699 247176 temp_mapscr->warpreturny[2]=0;
15700 247176 temp_mapscr->warpreturny[3]=0;
15701
15702
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15703 {
15704
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15705 {
15706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
15707 {
15708 return qe_invalid;
15709 }
15710 460224 }
15711
15712
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(version>=18)
15713 {
15714
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&temp_mapscr->warpreturnc,f))
15715 {
15716 return qe_invalid;
15717 }
15718 153408 }
15719 else
15720 {
15721 byte temp;
15722
15723 if(!p_getc(&temp,f))
15724 {
15725 return qe_invalid;
15726 }
15727
15728 temp_mapscr->warpreturnc=temp<<8|temp;
15729 }
15730 153408 }
15731
15732
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->stairx),f))
15733
15734 {
15735 return qe_invalid;
15736 }
15737
15738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->stairy),f))
15739 {
15740 return qe_invalid;
15741 }
15742
15743
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->itemx),f))
15744 {
15745 return qe_invalid;
15746 }
15747
15748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->itemy),f))
15749 {
15750 return qe_invalid;
15751 }
15752
15753
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version > 15) // February 2009
15754 {
15755
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&(temp_mapscr->color),f))
15756 {
15757 return qe_invalid;
15758 }
15759 153408 }
15760 else
15761 {
15762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93768 times.
93768 if(!p_getc(& tempbyte,f))
15763 {
15764 return qe_invalid;
15765 }
15766
15767 93768 temp_mapscr->color = (word) tempbyte;
15768 }
15769
15770
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->enemyflags),f))
15771 {
15772 return qe_invalid;
15773 }
15774
15775
2/2
✓ Branch 0 taken 988704 times.
✓ Branch 1 taken 247176 times.
1235880 for(int32_t k=0; k<4; k++)
15776 {
15777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 988704 times.
988704 if(!p_getc(&(temp_mapscr->door[k]),f))
15778 {
15779 return qe_invalid;
15780
15781 }
15782 988704 }
15783
15784
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version <= 11)
15785 {
15786
1/2
✓ Branch 0 taken 93768 times.
✗ Branch 1 not taken.
93768 if(!p_getc(&(tempbyte),f))
15787 {
15788 return qe_invalid;
15789 }
15790
15791 93768 temp_mapscr->tilewarpdmap[0]=(word)tempbyte;
15792
15793
2/6
✓ Branch 0 taken 93768 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
93768 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15794 {
15795 for(int32_t i=1; i<4; i++)
15796 {
15797 if(!p_getc(&(tempbyte),f))
15798 {
15799 return qe_invalid;
15800 }
15801
15802 temp_mapscr->tilewarpdmap[i]=(word)tempbyte;
15803 }
15804 }
15805 else
15806 {
15807 93768 temp_mapscr->tilewarpdmap[1]=0;
15808 93768 temp_mapscr->tilewarpdmap[2]=0;
15809 93768 temp_mapscr->tilewarpdmap[3]=0;
15810 }
15811 93768 }
15812 else
15813 {
15814
2/2
✓ Branch 0 taken 613632 times.
✓ Branch 1 taken 153408 times.
767040 for(int32_t i=0; i<4; i++)
15815 {
15816
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 613632 times.
613632 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
15817 {
15818 return qe_invalid;
15819 }
15820 613632 }
15821 }
15822
15823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->tilewarpscr[0]),f))
15824 {
15825 return qe_invalid;
15826 }
15827
15828
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15829 {
15830
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15831 {
15832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
15833 {
15834 return qe_invalid;
15835 }
15836 460224 }
15837 153408 }
15838 else
15839 {
15840 93768 temp_mapscr->tilewarpscr[1]=0;
15841 93768 temp_mapscr->tilewarpscr[2]=0;
15842 93768 temp_mapscr->tilewarpscr[3]=0;
15843 }
15844
15845
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version >= 15)
15846 {
15847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
15848 {
15849 return qe_invalid;
15850 }
15851 153408 }
15852 else
15853 {
15854 93768 temp_mapscr->tilewarpoverlayflags=0;
15855 }
15856
15857
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->exitdir),f))
15858 {
15859 return qe_invalid;
15860 }
15861
15862
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
247176 if(Header->zelda_version < 0x193)
15863 {
15864
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&tempbyte,f))
15865 {
15866 return qe_invalid;
15867 }
15868
15869 6864 }
15870
15871
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version == 0x192)&&(Header->build>145)&&(Header->build<154))
15872 {
15873 if(!p_getc(&padding,f))
15874 {
15875 return qe_invalid;
15876 }
15877 }
15878
15879
2/2
✓ Branch 0 taken 2471760 times.
✓ Branch 1 taken 247176 times.
2718936 for(int32_t k=0; k<10; k++)
15880 {
15881 /*
15882 if (!temp_mapscr->enemy[k])
15883 {
15884 continue;
15885 }
15886 */
15887
3/6
✓ Branch 0 taken 2403120 times.
✓ Branch 1 taken 68640 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2403120 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2471760 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<10)))
15888 {
15889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68640 times.
68640 if(!p_getc(&tempbyte,f))
15890 {
15891 return qe_invalid;
15892 }
15893
15894 68640 temp_mapscr->enemy[k]=tempbyte;
15895 68640 }
15896 else
15897 {
15898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2403120 times.
2403120 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
15899 {
15900 return qe_invalid;
15901 }
15902 }
15903
15904
3/6
✓ Branch 0 taken 2403120 times.
✓ Branch 1 taken 68640 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2403120 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2471760 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<108)))
15905 {
15906 //using enumerations here is dangerous
15907 //very easy to break old quests -DD
15908
2/2
✓ Branch 0 taken 788 times.
✓ Branch 1 taken 67852 times.
68640 if(temp_mapscr->enemy[k]>=57) //old eGOHMA1
15909 {
15910 788 temp_mapscr->enemy[k]+=5;
15911 788 }
15912
2/2
✓ Branch 0 taken 67812 times.
✓ Branch 1 taken 40 times.
67852 else if(temp_mapscr->enemy[k]>=52) //old eGLEEOK2
15913 {
15914 40 temp_mapscr->enemy[k]+=1;
15915 40 }
15916 68640 }
15917
15918
2/2
✓ Branch 0 taken 1534080 times.
✓ Branch 1 taken 937680 times.
2471760 if(version < 9)
15919 {
15920
2/2
✓ Branch 0 taken 856505 times.
✓ Branch 1 taken 81175 times.
937680 if(temp_mapscr->enemy[k]>0)
15921 {
15922 81175 temp_mapscr->enemy[k]+=10;
15923 81175 }
15924 937680 }
15925 //don't read in any invalid data
15926
2/2
✓ Branch 0 taken 2471670 times.
✓ Branch 1 taken 90 times.
2471760 if ( ((unsigned)temp_mapscr->enemy[k]) > MAXGUYS )
15927 {
15928 90 al_trace("Tried to read an invalid enemy ID (%d) for tmpscr->enemy[%d]. This has been cleared to 0.\n", temp_mapscr->enemy[k], k);
15929 90 temp_mapscr->enemy[k] = 0;
15930 90 }
15931 2471760 }
15932
15933
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->pattern),f))
15934 {
15935 return qe_invalid;
15936 }
15937
15938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->sidewarptype[0]),f))
15939 {
15940 return qe_invalid;
15941 }
15942
15943
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15944 {
15945
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15946 {
15947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
15948 {
15949 return qe_invalid;
15950 }
15951 460224 }
15952 153408 }
15953 else
15954 {
15955 93768 temp_mapscr->sidewarptype[1]=0;
15956 93768 temp_mapscr->sidewarptype[2]=0;
15957 93768 temp_mapscr->sidewarptype[3]=0;
15958 }
15959
15960
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version >= 15)
15961 {
15962
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
15963 {
15964 return qe_invalid;
15965 }
15966 153408 }
15967 else
15968 {
15969 93768 temp_mapscr->sidewarpoverlayflags=0;
15970 }
15971
15972
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->warparrivalx),f))
15973 {
15974 return qe_invalid;
15975 }
15976
15977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->warparrivaly),f))
15978 {
15979 return qe_invalid;
15980 }
15981
15982
2/2
✓ Branch 0 taken 988704 times.
✓ Branch 1 taken 247176 times.
1235880 for(int32_t k=0; k<4; k++)
15983 {
15984
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 988704 times.
988704 if(!p_getc(&(temp_mapscr->path[k]),f))
15985 {
15986 return qe_invalid;
15987 }
15988 988704 }
15989
15990
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->sidewarpscr[0]),f))
15991 {
15992 return qe_invalid;
15993 }
15994
15995
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15996 {
15997
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 460224 times.
613632 for(int32_t i=1; i<4; i++)
15998 {
15999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
16000 {
16001 return qe_invalid;
16002 }
16003 460224 }
16004 153408 }
16005 else
16006 {
16007 93768 temp_mapscr->sidewarpscr[1]=0;
16008 93768 temp_mapscr->sidewarpscr[2]=0;
16009 93768 temp_mapscr->sidewarpscr[3]=0;
16010 }
16011
16012
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version <= 11)
16013 {
16014
1/2
✓ Branch 0 taken 93768 times.
✗ Branch 1 not taken.
93768 if(!p_getc(&(tempbyte),f))
16015 {
16016 return qe_invalid;
16017 }
16018
16019 93768 temp_mapscr->sidewarpdmap[0]=(word)tempbyte;
16020
16021
2/6
✓ Branch 0 taken 93768 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
93768 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16022 {
16023 for(int32_t i=1; i<4; i++)
16024 {
16025 if(!p_getc(&(tempbyte),f))
16026 {
16027 return qe_invalid;
16028 }
16029
16030 temp_mapscr->sidewarpdmap[i]=(word)tempbyte;
16031 }
16032 }
16033 else
16034 {
16035 93768 temp_mapscr->sidewarpdmap[1]=0;
16036 93768 temp_mapscr->sidewarpdmap[2]=0;
16037 93768 temp_mapscr->sidewarpdmap[3]=0;
16038 }
16039 93768 }
16040 else
16041 {
16042
2/2
✓ Branch 0 taken 613632 times.
✓ Branch 1 taken 153408 times.
767040 for(int32_t i=0; i<4; i++)
16043 {
16044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 613632 times.
613632 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
16045 {
16046 return qe_invalid;
16047 }
16048 613632 }
16049 }
16050
16051
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16052 {
16053
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
16054 {
16055 return qe_invalid;
16056 }
16057 153408 }
16058 93768 else temp_mapscr->sidewarpindex = 0;
16059
16060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_igetw(&(temp_mapscr->undercombo),f))
16061 {
16062 return qe_invalid;
16063 }
16064
16065
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
247176 if(Header->zelda_version < 0x193)
16066 {
16067
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&(temp_mapscr->old_cpage),f))
16068 {
16069 return qe_invalid;
16070 }
16071 6864 }
16072
16073
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->undercset),f)) //recalculated for older quests
16074 {
16075 return qe_invalid;
16076 }
16077
16078
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_igetw(&(temp_mapscr->catchall),f))
16079 {
16080 return qe_invalid;
16081 }
16082
16083
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->flags),f))
16084 {
16085 return qe_invalid;
16086 }
16087
16088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->flags2),f))
16089 {
16090 return qe_invalid;
16091 }
16092
16093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->flags3),f))
16094 {
16095 return qe_invalid;
16096 }
16097
16098
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>1)))
16099 //if (version>2)
16100 {
16101
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->flags4),f))
16102 {
16103 return qe_invalid;
16104 }
16105 153408 }
16106
16107
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16108 {
16109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->flags5),f))
16110 {
16111 return qe_invalid;
16112 }
16113
16114
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&(temp_mapscr->noreset),f))
16115 {
16116 return qe_invalid;
16117 }
16118
16119
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&(temp_mapscr->nocarry),f))
16120 {
16121 return qe_invalid;
16122 }
16123
16124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(temp_mapscr->flags5&32)
16125 {
16126 temp_mapscr->flags5 &= ~32;
16127 temp_mapscr->noreset |= 48;
16128 }
16129
16130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(version<8)
16131 {
16132 if(temp_mapscr->noreset&1)
16133 {
16134 temp_mapscr->noreset|=8192;
16135 }
16136
16137 if(temp_mapscr->nocarry&1)
16138 {
16139 temp_mapscr->nocarry|=8192;
16140 temp_mapscr->nocarry&=~1;
16141 }
16142 }
16143 153408 }
16144 else
16145 {
16146 93768 temp_mapscr->flags5 = 0;
16147 93768 temp_mapscr->noreset = 0;
16148 93768 temp_mapscr->nocarry = 0;
16149 }
16150
16151
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>9)))
16152 {
16153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->flags6),f))
16154 {
16155 return qe_invalid;
16156 }
16157 153408 }
16158
16159
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version>5)
16160 {
16161
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->flags7),f))
16162 {
16163 return qe_invalid;
16164 }
16165
16166
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->flags8),f))
16167 {
16168 return qe_invalid;
16169 }
16170
16171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->flags9),f))
16172 {
16173 return qe_invalid;
16174 }
16175
16176
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->flags10),f))
16177 {
16178 return qe_invalid;
16179 }
16180
16181
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->csensitive),f))
16182 {
16183 return qe_invalid;
16184 }
16185 153408 }
16186 else
16187 {
16188 93768 temp_mapscr->csensitive=1;
16189 }
16190
16191
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version<14) // August 2007: screen SFX added
16192 {
16193
2/2
✓ Branch 0 taken 93668 times.
✓ Branch 1 taken 100 times.
93768 if(temp_mapscr->flags&8) //fROAR
16194 {
16195 100 temp_mapscr->bosssfx=
16196
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 91 times.
100 (temp_mapscr->flags3&2) ? WAV_DODONGO : // fDODONGO
16197 91 (temp_mapscr->flags2&32) ? WAV_VADER : // fVADER
16198 WAV_ROAR;
16199 100 }
16200
16201
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 93677 times.
93768 if(temp_mapscr->flags&128) //fSEA
16202 {
16203 91 temp_mapscr->oceansfx=WAV_SEA;
16204 91 }
16205
16206 93768 temp_mapscr->secretsfx = (temp_mapscr->flags3&64) //fNOSECRETSOUND
16207 ? 0 : WAV_SECRET;
16208
16209 93768 temp_mapscr->flags3 &= ~66; //64|2
16210 93768 temp_mapscr->flags2 &= ~32;
16211 93768 temp_mapscr->flags &= ~136; // 128|8
16212 93768 }
16213 else
16214 {
16215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->oceansfx),f))
16216 {
16217 return qe_invalid;
16218 }
16219
16220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->bosssfx),f))
16221 {
16222 return qe_invalid;
16223 }
16224
16225
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->secretsfx),f))
16226 {
16227 return qe_invalid;
16228 }
16229 }
16230
16231
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version<15) // October 2007: another SFX
16232 {
16233 93768 temp_mapscr->holdupsfx=WAV_PICKUP;
16234 93768 }
16235 else
16236 {
16237
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->holdupsfx),f))
16238 {
16239 return qe_invalid;
16240 }
16241 }
16242
16243
16244
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16245 {
16246
2/2
✓ Branch 0 taken 1441872 times.
✓ Branch 1 taken 240312 times.
1682184 for(int32_t k=0; k<6; k++)
16247 {
16248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1441872 times.
1441872 if(!p_getc(&(temp_mapscr->layermap[k]),f))
16249 {
16250 return qe_invalid;
16251 }
16252 1441872 }
16253
16254
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 1441872 times.
1682184 for(int32_t k=0; k<6; k++)
16255 {
16256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1441872 times.
1441872 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
16257 {
16258 return qe_invalid;
16259 }
16260 1441872 }
16261 240312 }
16262
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6864 else if((Header->zelda_version == 0x192)&&(Header->build>23)&&(Header->build<98))
16263 {
16264 if(!p_getc(&(temp_mapscr->layermap[2]),f))
16265 {
16266 return qe_invalid;
16267 }
16268
16269 if(!p_getc(&(temp_mapscr->layerscreen[2]),f))
16270 {
16271 return qe_invalid;
16272 }
16273
16274 if(!p_getc(&(temp_mapscr->layermap[4]),f))
16275 {
16276 return qe_invalid;
16277 }
16278
16279 if(!p_getc(&(temp_mapscr->layerscreen[4]),f))
16280
16281 {
16282 return qe_invalid;
16283 }
16284 }
16285
16286
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
247176 if((Header->zelda_version == 0x192)&&(Header->build>149))
16287 {
16288 for(int32_t k=0; k<6; k++)
16289 {
16290 if(!p_getc(&tempbyte,f)) //layerxsize
16291 {
16292 return qe_invalid;
16293 }
16294 }
16295
16296 for(int32_t k=0; k<6; k++)
16297 {
16298 if(!p_getc(&tempbyte,f)) //layerxspeed
16299 {
16300 return qe_invalid;
16301 }
16302 }
16303
16304 for(int32_t k=0; k<6; k++)
16305 {
16306 if(!p_getc(&tempbyte,f)) //layerxdelay
16307 {
16308 return qe_invalid;
16309 }
16310 }
16311
16312 for(int32_t k=0; k<6; k++)
16313 {
16314 if(!p_getc(&tempbyte,f)) //layerysize
16315 {
16316 return qe_invalid;
16317 }
16318 }
16319
16320 for(int32_t k=0; k<6; k++)
16321 {
16322 if(!p_getc(&tempbyte,f)) //layeryspeed
16323 {
16324 return qe_invalid;
16325 }
16326 }
16327
16328 for(int32_t k=0; k<6; k++)
16329 {
16330 if(!p_getc(&tempbyte,f)) //layerydelay
16331 {
16332 return qe_invalid;
16333 }
16334 }
16335 }
16336
16337
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>149)))
16338 {
16339
2/2
✓ Branch 0 taken 1441872 times.
✓ Branch 1 taken 240312 times.
1682184 for(int32_t k=0; k<6; k++)
16340 {
16341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1441872 times.
1441872 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
16342 {
16343 return qe_invalid;
16344 }
16345 1441872 }
16346 240312 }
16347
16348
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16349 {
16350
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 if((Header->zelda_version == 0x192)&&(Header->build>153))
16351 {
16352 if(!p_getc(&padding,f))
16353 {
16354 return qe_invalid;
16355 }
16356 }
16357
16358
1/2
✓ Branch 0 taken 240312 times.
✗ Branch 1 not taken.
240312 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
16359 {
16360 return qe_invalid;
16361 }
16362 240312 }
16363
16364
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<24)))
16365 {
16366 6864 extras=15;
16367 6864 }
16368
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 else if(((Header->zelda_version == 0x192)&&(Header->build<98)))
16369 {
16370 extras=11;
16371 }
16372
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 else if((Header->zelda_version == 0x192)&&(Header->build<150))
16373 {
16374 extras=32;
16375 }
16376
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16377 {
16378 extras=64;
16379 }
16380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
240312 else if(Header->zelda_version < 0x193)
16381 {
16382 extras=62;
16383 }
16384 else
16385
16386 {
16387 240312 extras=0;
16388 }
16389
16390
2/2
✓ Branch 0 taken 102960 times.
✓ Branch 1 taken 247176 times.
350136 for(int32_t k=0; k<extras; k++)
16391 {
16392
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102960 times.
102960 if(!p_getc(&tempbyte,f)) //extra[k]
16393 {
16394 return qe_invalid;
16395 }
16396 102960 }
16397
16398
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>2)))
16399 //if (version>3)
16400 {
16401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->nextmap),f))
16402 {
16403 return qe_invalid;
16404 }
16405
16406
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->nextscr),f))
16407 {
16408 return qe_invalid;
16409 }
16410 153408 }
16411 else
16412 {
16413 93768 temp_mapscr->nextmap=0;
16414 93768 temp_mapscr->nextscr=0;
16415 }
16416
16417
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16418 {
16419 6864 secretcombos=20;
16420 6864 }
16421
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16422 {
16423 secretcombos=256;
16424 }
16425 else
16426 {
16427 240312 secretcombos=128;
16428 }
16429
16430
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16431 {
16432
2/2
✓ Branch 0 taken 137280 times.
✓ Branch 1 taken 6864 times.
144144 for(int32_t k=0; k<secretcombos; k++)
16433 {
16434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137280 times.
137280 if(!p_getc(&tempbyte,f))
16435 {
16436 return qe_invalid;
16437 }
16438
16439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137280 times.
137280 if(k<128)
16440 {
16441 137280 temp_mapscr->secretcombo[k]=tempbyte;
16442 137280 }
16443 137280 }
16444 6864 }
16445 else
16446 {
16447
2/2
✓ Branch 0 taken 30759936 times.
✓ Branch 1 taken 240312 times.
31000248 for(int32_t k=0; k<128; k++)
16448 {
16449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30759936 times.
30759936 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
16450 {
16451 return qe_invalid;
16452 }
16453
16454 30759936 }
16455 }
16456
16457
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16458 {
16459
2/2
✓ Branch 0 taken 30759936 times.
✓ Branch 1 taken 240312 times.
31000248 for(int32_t k=0; k<128; k++)
16460 {
16461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30759936 times.
30759936 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
16462 {
16463 return qe_invalid;
16464 }
16465 30759936 }
16466
16467
2/2
✓ Branch 0 taken 30759936 times.
✓ Branch 1 taken 240312 times.
31000248 for(int32_t k=0; k<128; k++)
16468 {
16469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30759936 times.
30759936 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
16470 {
16471 return qe_invalid;
16472 }
16473 30759936 }
16474 240312 }
16475
16476
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version == 0x192)&&(Header->build>97)&&(Header->build<154))
16477 {
16478 if(!p_getc(&padding,f))
16479 {
16480 return qe_invalid;
16481 }
16482 }
16483
16484 247176 const int32_t _mapsSize = (temp_map->tileWidth*temp_map->tileHeight);
16485
16486
2/2
✓ Branch 0 taken 43502976 times.
✓ Branch 1 taken 247176 times.
43750152 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16487 {
16488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43502976 times.
43502976 if(!p_igetw(&(temp_mapscr->data[k]),f))
16489 {
16490 return qe_invalid;
16491 }
16492 43502976 }
16493
16494
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version == 0x192)&&(Header->build>20)&&(Header->build<24))
16495 {
16496 if(!p_getc(&padding,f))
16497 {
16498 return qe_invalid;
16499 }
16500
16501 if(!p_getc(&padding,f))
16502 {
16503 return qe_invalid;
16504 }
16505 }
16506
16507
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>20)))
16508 {
16509
2/2
✓ Branch 0 taken 42294912 times.
✓ Branch 1 taken 240312 times.
42535224 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16510 {
16511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42294912 times.
42294912 if(!p_getc(&(temp_mapscr->sflag[k]),f))
16512 {
16513 return qe_invalid;
16514 }
16515
16516
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 42294912 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
42294912 if((Header->zelda_version == 0x192)&&(Header->build<24))
16517 {
16518 if(!p_getc(&tempbyte,f))
16519 {
16520 return qe_invalid;
16521 }
16522
16523 if(!p_getc(&tempbyte,f))
16524 {
16525 return qe_invalid;
16526 }
16527
16528 if(!p_getc(&tempbyte,f))
16529 {
16530 return qe_invalid;
16531 }
16532 }
16533 42294912 }
16534 240312 }
16535
16536
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16537 {
16538
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 42294912 times.
42535224 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16539 {
16540
16541
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42294912 times.
42294912 if(!p_getc(&(temp_mapscr->cset[k]),f))
16542 {
16543 return qe_invalid;
16544 }
16545 42294912 }
16546 240312 }
16547
16548
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16549 {
16550 6864 temp_mapscr->undercset=(temp_mapscr->undercombo>>8)&7;
16551 6864 temp_mapscr->undercombo=(temp_mapscr->undercombo&0xFF)+(temp_mapscr->old_cpage<<8);
16552 6864 }
16553
16554
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16555 {
16556 6864 temp_mapscr->secretcombo[sSBOMB]=temp_mapscr->secretcombo[sBOMB];
16557 6864 temp_mapscr->secretcombo[sRCANDLE]=temp_mapscr->secretcombo[sBCANDLE];
16558 6864 temp_mapscr->secretcombo[sWANDFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16559 6864 temp_mapscr->secretcombo[sDIVINEFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16560 6864 temp_mapscr->secretcombo[sSARROW]=temp_mapscr->secretcombo[sARROW];
16561 6864 temp_mapscr->secretcombo[sGARROW]=temp_mapscr->secretcombo[sARROW];
16562 6864 }
16563
16564
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16565 {
16566
2/2
✓ Branch 0 taken 1208064 times.
✓ Branch 1 taken 6864 times.
1214928 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16567 {
16568
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1208064 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1208064 if((Header->zelda_version == 0x192)&&(Header->build>149))
16569 {
16570 if((Header->zelda_version == 0x192)&&(Header->build!=153))
16571 {
16572 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16573 }
16574 }
16575 else
16576 {
16577
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1208064 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1208064 if((Header->zelda_version < 0x192)||
16578 ((Header->zelda_version == 0x192)&&(Header->build<21)))
16579 {
16580 1208064 temp_mapscr->sflag[k]=(temp_mapscr->data[k]>>11);
16581 1208064 }
16582
16583 1208064 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16584 }
16585
16586 1208064 temp_mapscr->data[k]=(temp_mapscr->data[k]&0xFF)+(temp_mapscr->old_cpage<<8);
16587 1208064 }
16588 6864 }
16589
16590 /*if(version>12)
16591 {
16592 if(!p_getc(&(temp_mapscr->scrWidth),f))
16593 {
16594 return qe_invalid;
16595 }
16596 if(!p_getc(&(temp_mapscr->scrHeight),f))
16597 {
16598 return qe_invalid;
16599 }
16600 }*/
16601
16602
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version>4)
16603 {
16604
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&(temp_mapscr->screen_midi),f))
16605 {
16606 return qe_invalid;
16607 }
16608 153408 }
16609 else
16610 {
16611 93768 temp_mapscr->screen_midi = -1;
16612 }
16613
16614
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version>=17)
16615 {
16616
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->lens_layer),f))
16617 {
16618 return qe_invalid;
16619 }
16620 153408 }
16621 else
16622 {
16623 93768 temp_mapscr->lens_layer = llNORMAL;
16624 }
16625
16626
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version>6)
16627 {
16628 dword bits;
16629
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_igetl(&bits,f))
16630 {
16631 return qe_invalid;
16632 }
16633
16634 int32_t m;
16635 float tempfloat;
16636 word tempw;
16637 153408 temp_mapscr->ffcCountMarkDirty();
16638
16639
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 4909056 times.
5062464 for(m=0; m<32; m++)
16640 {
16641 4909056 ffcdata& tempffc = temp_mapscr->ffcs[m];
16642 4909056 tempffc.clear();
16643
2/2
✓ Branch 0 taken 4886067 times.
✓ Branch 1 taken 22989 times.
4909056 if((bits>>m)&1)
16644 {
16645
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(!p_igetw(&tempw,f))
16646 {
16647 return qe_invalid;
16648 }
16649 22989 tempffc.setData(tempw);
16650
16651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&(tempffc.cset),f))
16652 {
16653 return qe_invalid;
16654 }
16655
16656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetw(&(tempffc.delay),f))
16657 {
16658 return qe_invalid;
16659 }
16660
16661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(version < 9)
16662 {
16663 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16664 {
16665 return qe_invalid;
16666 }
16667
16668 tempffc.x=zslongToFix(int32_t(tempfloat*10000));
16669
16670 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16671 {
16672 return qe_invalid;
16673 }
16674
16675 tempffc.y=zslongToFix(int32_t(tempfloat*10000));
16676
16677 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16678 {
16679 return qe_invalid;
16680 }
16681
16682 tempffc.vx=zslongToFix(int32_t(tempfloat*10000));
16683
16684 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16685 {
16686 return qe_invalid;
16687 }
16688
16689 tempffc.vy=zslongToFix(int32_t(tempfloat*10000));
16690
16691 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16692 {
16693 return qe_invalid;
16694 }
16695
16696 tempffc.ax=zslongToFix(int32_t(tempfloat*10000));
16697
16698 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16699 {
16700 return qe_invalid;
16701 }
16702
16703 tempffc.ay=zslongToFix(int32_t(tempfloat*10000));
16704 }
16705 else
16706 {
16707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.x),f))
16708 {
16709 return qe_invalid;
16710 }
16711
16712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.y),f))
16713 {
16714 return qe_invalid;
16715 }
16716
16717
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(!p_igetzf(&(tempffc.vx),f))
16718 {
16719 return qe_invalid;
16720 }
16721
16722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.vy),f))
16723 {
16724 return qe_invalid;
16725 }
16726
16727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.ax),f))
16728 {
16729 return qe_invalid;
16730 }
16731
16732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.ay),f))
16733 {
16734 return qe_invalid;
16735 }
16736 }
16737
16738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&(tempffc.link),f))
16739 {
16740 return qe_invalid;
16741 }
16742
16743
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(version>7)
16744 {
16745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&tempbyte,f))
16746 {
16747 return qe_invalid;
16748 }
16749
16750 22989 tempffc.hit_width = (tempbyte&0x3F)+1;
16751 22989 tempffc.txsz = (tempbyte>>6)+1;
16752
16753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&tempbyte,f))
16754 {
16755 return qe_invalid;
16756 }
16757
16758 22989 tempffc.hit_height = (tempbyte&0x3F)+1;
16759 22989 tempffc.tysz = (tempbyte>>6)+1;
16760
16761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.flags),f))
16762 {
16763 return qe_invalid;
16764 }
16765 22989 }
16766 else
16767 {
16768 tempffc.hit_width=16;
16769 tempffc.hit_height=16;
16770 tempffc.txsz=1;
16771 tempffc.tysz=1;
16772 tempffc.flags=0;
16773 }
16774
16775 22989 tempffc.updateSolid();
16776
16777
16778
4/6
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20969 times.
✓ Branch 3 taken 2020 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 20969 times.
22989 if(Header->zelda_version == 0x211 || (Header->zelda_version == 0x250 && Header->build<20))
16779 {
16780 tempffc.flags|=ffIGNOREHOLDUP;
16781 }
16782
16783
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(version>9)
16784 {
16785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetw(&(tempffc.script),f))
16786 {
16787 return qe_invalid;
16788 }
16789 22989 }
16790 else
16791 {
16792 tempffc.script=0;
16793 }
16794
16795
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(version>10)
16796 {
16797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[0]),f))
16798 {
16799 return qe_invalid;
16800 }
16801
16802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[1]),f))
16803 {
16804 return qe_invalid;
16805 }
16806
16807
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[2]),f))
16808 {
16809 return qe_invalid;
16810 }
16811
16812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[3]),f))
16813 {
16814 return qe_invalid;
16815 }
16816
16817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[4]),f))
16818 {
16819 return qe_invalid;
16820 }
16821
16822
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[5]),f))
16823 {
16824 return qe_invalid;
16825 }
16826
16827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[6]),f))
16828 {
16829 return qe_invalid;
16830 }
16831
16832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[7]),f))
16833 {
16834 return qe_invalid;
16835 }
16836
16837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&(tempbyte),f))
16838 {
16839 return qe_invalid;
16840 }
16841
16842 22989 tempffc.inita[0]=tempbyte*10000;
16843
16844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&(tempbyte),f))
16845 {
16846 return qe_invalid;
16847 }
16848
16849 22989 tempffc.inita[1]=tempbyte*10000;
16850 22989 }
16851 else
16852 {
16853 tempffc.inita[0] = 10000;
16854 tempffc.inita[1] = 10000;
16855 }
16856
16857
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(version <= 11)
16858 {
16859 fixffcs=true;
16860 }
16861 22989 }
16862 4909056 }
16863
2/2
✓ Branch 0 taken 14727168 times.
✓ Branch 1 taken 153408 times.
14880576 for(m = 32; m < MAXFFCS; ++m)
16864 {
16865 14727168 temp_mapscr->ffcs[m].clear();
16866 14727168 }
16867 153408 }
16868
16869 //add in the new whistle flags
16870
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version<13)
16871 {
16872
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 93749 times.
93768 if(temp_mapscr->flags & fWHISTLE)
16873 {
16874 19 temp_mapscr->flags7 |= (fWHISTLEPAL | fWHISTLEWATER);
16875 19 }
16876 93768 }
16877
16878 //2.55 starts here
16879
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
247176 if ( version >= 19 && Header->zelda_version > 0x253 )
16880 {
16881
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16882 {
16883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f))
16884 {
16885 return qe_invalid;
16886 }
16887 137360 }
16888
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16889 {
16890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_items[q]),f))
16891 {
16892 return qe_invalid;
16893 }
16894 137360 }
16895
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16896 {
16897
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f))
16898 {
16899 return qe_invalid;
16900 }
16901 137360 }
16902
2/2
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 137360 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16903 {
16904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f))
16905 {
16906 return qe_invalid;
16907 }
16908 137360 }
16909 13736 }
16910
3/4
✓ Branch 0 taken 233440 times.
✓ Branch 1 taken 13736 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 233440 times.
247176 if ( version < 19 && Header->zelda_version > 0x253 )
16911 {
16912 for ( int32_t q = 0; q < 10; q++ )
16913 {
16914 temp_mapscr->npcstrings[q] = 0;
16915 temp_mapscr->new_items[q] = 0;
16916 temp_mapscr->new_item_x[q] = 0;
16917 temp_mapscr->new_item_y[q] = 0;
16918 }
16919 }
16920
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
247176 if ( version >= 20 && Header->zelda_version > 0x253 )
16921 {
16922
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_igetw(&(temp_mapscr->script),f))
16923 {
16924 return qe_invalid;
16925 }
16926
2/2
✓ Branch 0 taken 109888 times.
✓ Branch 1 taken 13736 times.
123624 for ( int32_t q = 0; q < 8; q++)
16927 {
16928
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109888 times.
109888 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
16929 {
16930 return qe_invalid;
16931 }
16932 109888 }
16933 13736 }
16934
2/2
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
247176 if ( version < 20 )
16935 {
16936 233440 temp_mapscr->script = 0;
16937
2/2
✓ Branch 0 taken 1867520 times.
✓ Branch 1 taken 233440 times.
2100960 for ( int32_t q = 0; q < 8; q++) temp_mapscr->screeninitd[q] = 0;
16938 233440 }
16939
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
247176 if ( version >= 21 && Header->zelda_version > 0x253 )
16940 {
16941
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_getc(&(temp_mapscr->preloadscript),f))
16942 {
16943 return qe_invalid;
16944 }
16945 13736 }
16946
2/2
✓ Branch 0 taken 233440 times.
✓ Branch 1 taken 13736 times.
247176 if ( version < 21 )
16947 {
16948 233440 temp_mapscr->preloadscript = 0;
16949 233440 }
16950 //all builds with version > 20 need this. -Z
16951
16952
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
247176 if ( version >= 22 && Header->zelda_version > 0x253 ) //26th June, 2019; Layer Visibility
16953 {
16954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13736 times.
13736 if(!p_getc(&(temp_mapscr->hidelayers ),f))
16955 {
16956 return qe_invalid;
16957 }
16958
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_getc(&(temp_mapscr->hidescriptlayers ),f))
16959 {
16960 return qe_invalid;
16961 }
16962 13736 }
16963
2/2
✓ Branch 0 taken 233440 times.
✓ Branch 1 taken 13736 times.
247176 if ( version < 22 )
16964 {
16965 233440 temp_mapscr->hidelayers = 0;
16966 233440 temp_mapscr->hidescriptlayers = 0;
16967 233440 }
16968
16969 //Dodongos in 2.10 used the boss roar, not the dodongo sound. -Z
16970 //May be any version before 2.11. -Z
16971 /* --not the roar, the HIT SFX
16972 if ( Header->zelda_version <= 0x210 )
16973 {
16974 if ( temp_mapscr->bosssfx == WAV_DODONGO )
16975 {
16976 temp_mapscr->bosssfx = WAV_ROAR;
16977 }
16978 }
16979 */
16980
16981 247176 return 0;
16982 247176 }
16983 263632 int32_t readmapscreen(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, zcmap *temp_map, word version, int scrind)
16984 {
16985
2/2
✓ Branch 0 taken 247176 times.
✓ Branch 1 taken 16456 times.
263632 if(version < 23)
16986 {
16987 247176 auto ret = readmapscreen_old(f,Header,temp_mapscr,temp_map,version);
16988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(ret) return ret;
16989 247176 }
16990 else
16991 {
16992
1/2
✓ Branch 0 taken 16456 times.
✗ Branch 1 not taken.
16456 if(!p_getc(&(temp_mapscr->valid),f))
16993 return qe_invalid;
16994
2/2
✓ Branch 0 taken 10383 times.
✓ Branch 1 taken 6073 times.
16456 if(!(temp_mapscr->valid & mVALID))
16995 {
16996 10383 int map = scrind/MAPSCRS;
16997 10383 int scr = scrind%MAPSCRS;
16998
4/6
✓ Branch 0 taken 4484 times.
✓ Branch 1 taken 5899 times.
✓ Branch 2 taken 4484 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4484 times.
✗ Branch 5 not taken.
10383 if(version > 25 && scrind > -1 && (map*6+5) < map_autolayers.size())
16999 {
17000 //Empty screen, apply autolayers
17001
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4484 times.
4484 for(int q = 0; q < 6; ++q)
17002 {
17003 auto layermap = map_autolayers[map*6+q];
17004 temp_mapscr->layermap[q] = layermap;
17005 if(layermap)
17006 temp_mapscr->layerscreen[q] = scr;
17007 }
17008 4484 }
17009 10383 return 0;
17010 }
17011 uint32_t scr_has_flags;
17012
1/2
✓ Branch 0 taken 6073 times.
✗ Branch 1 not taken.
6073 if(!p_igetl(&scr_has_flags,f))
17013 return qe_invalid;
17014
17015
2/2
✓ Branch 0 taken 5329 times.
✓ Branch 1 taken 744 times.
6073 if(scr_has_flags & SCRHAS_ROOMDATA)
17016 {
17017
1/2
✓ Branch 0 taken 744 times.
✗ Branch 1 not taken.
744 if(!p_getc(&(temp_mapscr->guy),f))
17018 return qe_invalid;
17019
2/2
✓ Branch 0 taken 684 times.
✓ Branch 1 taken 60 times.
744 if(version > 26)
17020 {
17021
1/2
✓ Branch 0 taken 684 times.
✗ Branch 1 not taken.
684 if(!p_igetl(&(temp_mapscr->guytile),f))
17022 return qe_invalid;
17023
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 684 times.
684 if(!p_getc(&(temp_mapscr->guycs),f))
17024 return qe_invalid;
17025
1/2
✓ Branch 0 taken 684 times.
✗ Branch 1 not taken.
684 if(!p_igetw(&(temp_mapscr->roomflags),f))
17026 return qe_invalid;
17027 684 }
17028 else
17029 {
17030 60 temp_mapscr->guytile = -1; //signal to use default guy values
17031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
17032
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
60 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
17033 }
17034
1/2
✓ Branch 0 taken 744 times.
✗ Branch 1 not taken.
744 if(!p_igetw(&(temp_mapscr->str),f))
17035 return qe_invalid;
17036
1/2
✓ Branch 0 taken 744 times.
✗ Branch 1 not taken.
744 if(!p_getc(&(temp_mapscr->room),f))
17037 return qe_invalid;
17038
1/2
✓ Branch 0 taken 744 times.
✗ Branch 1 not taken.
744 if(!p_igetw(&(temp_mapscr->catchall),f))
17039 return qe_invalid;
17040 744 }
17041
2/2
✓ Branch 0 taken 5950 times.
✓ Branch 1 taken 123 times.
6073 if(scr_has_flags & SCRHAS_ITEM)
17042 {
17043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
123 if(!p_getc(&(temp_mapscr->item),f))
17044 return qe_invalid;
17045
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 if(!p_getc(&(temp_mapscr->hasitem),f))
17046 return qe_invalid;
17047
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
123 if(!p_getc(&(temp_mapscr->itemx),f))
17048 return qe_invalid;
17049
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 if(!p_getc(&(temp_mapscr->itemy),f))
17050 return qe_invalid;
17051 123 }
17052
2/2
✓ Branch 0 taken 5716 times.
✓ Branch 1 taken 357 times.
6073 if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP))
17053 {
17054
1/2
✓ Branch 0 taken 357 times.
✗ Branch 1 not taken.
357 if(!p_igetw(&temp_mapscr->warpreturnc,f))
17055 return qe_invalid;
17056 357 }
17057
2/2
✓ Branch 0 taken 5829 times.
✓ Branch 1 taken 244 times.
6073 if(scr_has_flags & SCRHAS_TWARP)
17058 {
17059
2/2
✓ Branch 0 taken 976 times.
✓ Branch 1 taken 244 times.
1220 for(int32_t i=0; i<4; i++)
17060 {
17061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 976 times.
976 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
17062 return qe_invalid;
17063 976 }
17064
2/2
✓ Branch 0 taken 976 times.
✓ Branch 1 taken 244 times.
1220 for(int32_t i=0; i<4; i++)
17065 {
17066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 976 times.
976 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
17067 return qe_invalid;
17068 976 }
17069
2/2
✓ Branch 0 taken 976 times.
✓ Branch 1 taken 244 times.
1220 for(int32_t i=0; i<4; i++)
17070 {
17071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 976 times.
976 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
17072 return qe_invalid;
17073 976 }
17074
1/2
✓ Branch 0 taken 244 times.
✗ Branch 1 not taken.
244 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
17075 return qe_invalid;
17076 244 }
17077
2/2
✓ Branch 0 taken 5934 times.
✓ Branch 1 taken 139 times.
6073 if(scr_has_flags & SCRHAS_SWARP)
17078 {
17079
2/2
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 139 times.
695 for(int32_t i=0; i<4; i++)
17080 {
17081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556 times.
556 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
17082 return qe_invalid;
17083 556 }
17084
2/2
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 139 times.
695 for(int32_t i=0; i<4; i++)
17085 {
17086
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556 times.
556 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
17087 return qe_invalid;
17088 556 }
17089
2/2
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 139 times.
695 for(int32_t i=0; i<4; i++)
17090 {
17091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556 times.
556 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
17092 return qe_invalid;
17093 556 }
17094
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
17095 return qe_invalid;
17096
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
17097 return qe_invalid;
17098 139 }
17099
2/2
✓ Branch 0 taken 5636 times.
✓ Branch 1 taken 437 times.
6073 if(scr_has_flags & SCRHAS_WARPRET)
17100 {
17101
2/2
✓ Branch 0 taken 1748 times.
✓ Branch 1 taken 437 times.
2185 for(int32_t i=0; i<4; i++)
17102 {
17103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1748 times.
1748 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
17104 return qe_invalid;
17105 1748 }
17106
2/2
✓ Branch 0 taken 1748 times.
✓ Branch 1 taken 437 times.
2185 for(int32_t i=0; i<4; i++)
17107 {
17108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1748 times.
1748 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
17109 return qe_invalid;
17110 1748 }
17111
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 437 times.
437 if(!p_getc(&(temp_mapscr->warparrivalx),f))
17112 return qe_invalid;
17113
1/2
✓ Branch 0 taken 437 times.
✗ Branch 1 not taken.
437 if(!p_getc(&(temp_mapscr->warparrivaly),f))
17114 return qe_invalid;
17115 437 }
17116
2/2
✓ Branch 0 taken 4945 times.
✓ Branch 1 taken 1128 times.
6073 if(scr_has_flags & SCRHAS_LAYERS)
17117 {
17118
2/2
✓ Branch 0 taken 6768 times.
✓ Branch 1 taken 1128 times.
7896 for(int32_t k=0; k<6; k++)
17119 {
17120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6768 times.
6768 if(!p_getc(&(temp_mapscr->layermap[k]),f))
17121 return qe_invalid;
17122 6768 }
17123
2/2
✓ Branch 0 taken 6768 times.
✓ Branch 1 taken 1128 times.
7896 for(int32_t k=0; k<6; k++)
17124 {
17125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6768 times.
6768 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
17126 return qe_invalid;
17127 6768 }
17128
2/2
✓ Branch 0 taken 6768 times.
✓ Branch 1 taken 1128 times.
7896 for(int32_t k=0; k<6; k++)
17129 {
17130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6768 times.
6768 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
17131 return qe_invalid;
17132 6768 }
17133
1/2
✓ Branch 0 taken 1128 times.
✗ Branch 1 not taken.
1128 if(!p_getc(&(temp_mapscr->hidelayers),f))
17134 return qe_invalid;
17135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1128 times.
1128 if(!p_getc(&(temp_mapscr->hidescriptlayers),f))
17136 return qe_invalid;
17137 1128 }
17138
1/2
✓ Branch 0 taken 6073 times.
✗ Branch 1 not taken.
6073 if(scr_has_flags & SCRHAS_MAZE)
17139 {
17140 for(int32_t k=0; k<4; k++)
17141 {
17142 if(!p_getc(&(temp_mapscr->path[k]),f))
17143 return qe_invalid;
17144 }
17145 if(!p_getc(&(temp_mapscr->exitdir),f))
17146 return qe_invalid;
17147 }
17148
2/2
✓ Branch 0 taken 5916 times.
✓ Branch 1 taken 157 times.
6073 if(scr_has_flags & SCRHAS_D_S_U)
17149 {
17150
1/2
✓ Branch 0 taken 157 times.
✗ Branch 1 not taken.
157 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
17151 return qe_invalid;
17152
2/2
✓ Branch 0 taken 628 times.
✓ Branch 1 taken 157 times.
785 for(int32_t k=0; k<4; k++)
17153 {
17154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 628 times.
628 if(!p_getc(&(temp_mapscr->door[k]),f))
17155 return qe_invalid;
17156 628 }
17157
17158
1/2
✓ Branch 0 taken 157 times.
✗ Branch 1 not taken.
157 if(!p_getc(&(temp_mapscr->stairx),f))
17159 return qe_invalid;
17160
17161
1/2
✓ Branch 0 taken 157 times.
✗ Branch 1 not taken.
157 if(!p_getc(&(temp_mapscr->stairy),f))
17162 return qe_invalid;
17163
1/2
✓ Branch 0 taken 157 times.
✗ Branch 1 not taken.
157 if(!p_igetw(&(temp_mapscr->undercombo),f))
17164 return qe_invalid;
17165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157 times.
157 if(!p_getc(&(temp_mapscr->undercset),f))
17166 return qe_invalid;
17167 157 }
17168
2/2
✓ Branch 0 taken 5637 times.
✓ Branch 1 taken 436 times.
6073 if(scr_has_flags & SCRHAS_FLAGS)
17169 {
17170
1/2
✓ Branch 0 taken 436 times.
✗ Branch 1 not taken.
436 if(!p_getc(&(temp_mapscr->flags),f))
17171 return qe_invalid;
17172
1/2
✓ Branch 0 taken 436 times.
✗ Branch 1 not taken.
436 if(!p_getc(&(temp_mapscr->flags2),f))
17173 return qe_invalid;
17174
1/2
✓ Branch 0 taken 436 times.
✗ Branch 1 not taken.
436 if(!p_getc(&(temp_mapscr->flags3),f))
17175 return qe_invalid;
17176
1/2
✓ Branch 0 taken 436 times.
✗ Branch 1 not taken.
436 if(!p_getc(&(temp_mapscr->flags4),f))
17177 return qe_invalid;
17178
1/2
✓ Branch 0 taken 436 times.
✗ Branch 1 not taken.
436 if(!p_getc(&(temp_mapscr->flags5),f))
17179 return qe_invalid;
17180
1/2
✓ Branch 0 taken 436 times.
✗ Branch 1 not taken.
436 if(!p_getc(&(temp_mapscr->flags6),f))
17181 return qe_invalid;
17182
1/2
✓ Branch 0 taken 436 times.
✗ Branch 1 not taken.
436 if(!p_getc(&(temp_mapscr->flags7),f))
17183 return qe_invalid;
17184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 436 times.
436 if(!p_getc(&(temp_mapscr->flags8),f))
17185 return qe_invalid;
17186
1/2
✓ Branch 0 taken 436 times.
✗ Branch 1 not taken.
436 if(!p_getc(&(temp_mapscr->flags9),f))
17187 return qe_invalid;
17188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 436 times.
436 if(!p_getc(&(temp_mapscr->flags10),f))
17189 return qe_invalid;
17190
1/2
✓ Branch 0 taken 436 times.
✗ Branch 1 not taken.
436 if(!p_getc(&(temp_mapscr->enemyflags),f))
17191 return qe_invalid;
17192 436 }
17193
2/2
✓ Branch 0 taken 5694 times.
✓ Branch 1 taken 379 times.
6073 if(scr_has_flags & SCRHAS_ENEMY)
17194 {
17195
2/2
✓ Branch 0 taken 3790 times.
✓ Branch 1 taken 379 times.
4169 for(int32_t k=0; k<10; k++)
17196 {
17197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3790 times.
3790 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
17198 return qe_invalid;
17199
1/2
✓ Branch 0 taken 3790 times.
✗ Branch 1 not taken.
3790 if (unsigned(temp_mapscr->enemy[k]) > MAXGUYS)
17200 temp_mapscr->enemy[k] = 0;
17201 3790 }
17202
1/2
✓ Branch 0 taken 379 times.
✗ Branch 1 not taken.
379 if(!p_getc(&(temp_mapscr->pattern),f))
17203 return qe_invalid;
17204 379 }
17205
2/2
✓ Branch 0 taken 6040 times.
✓ Branch 1 taken 33 times.
6073 if(scr_has_flags & SCRHAS_CARRY)
17206 {
17207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(!p_igetw(&(temp_mapscr->noreset),f))
17208 return qe_invalid;
17209
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_igetw(&(temp_mapscr->nocarry),f))
17210 return qe_invalid;
17211
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_getc(&(temp_mapscr->nextmap),f))
17212 return qe_invalid;
17213
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_getc(&(temp_mapscr->nextscr),f))
17214 return qe_invalid;
17215 33 }
17216
2/2
✓ Branch 0 taken 6004 times.
✓ Branch 1 taken 69 times.
6073 if(scr_has_flags & SCRHAS_SCRIPT)
17217 {
17218
1/2
✓ Branch 0 taken 69 times.
✗ Branch 1 not taken.
69 if(!p_igetw(&(temp_mapscr->script),f))
17219 return qe_invalid;
17220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 if(!p_getc(&(temp_mapscr->preloadscript),f))
17221 return qe_invalid;
17222
2/2
✓ Branch 0 taken 552 times.
✓ Branch 1 taken 69 times.
621 for ( int32_t q = 0; q < 8; q++ )
17223 {
17224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 552 times.
552 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
17225 return qe_invalid;
17226 552 }
17227 69 }
17228
1/2
✓ Branch 0 taken 6073 times.
✗ Branch 1 not taken.
6073 if(scr_has_flags & SCRHAS_UNUSED)
17229 {
17230 for ( int32_t q = 0; q < 10; q++ )
17231 {
17232 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f))
17233 return qe_invalid;
17234 }
17235 for ( int32_t q = 0; q < 10; q++ )
17236 {
17237 if(!p_igetw(&(temp_mapscr->new_items[q]),f))
17238 return qe_invalid;
17239 }
17240 for ( int32_t q = 0; q < 10; q++ )
17241 {
17242 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f))
17243 return qe_invalid;
17244 }
17245 for ( int32_t q = 0; q < 10; q++ )
17246 {
17247 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f))
17248 return qe_invalid;
17249 }
17250 }
17251
2/2
✓ Branch 0 taken 5652 times.
✓ Branch 1 taken 421 times.
6073 if(scr_has_flags & SCRHAS_SECRETS)
17252 {
17253
2/2
✓ Branch 0 taken 53888 times.
✓ Branch 1 taken 421 times.
54309 for(int32_t k=0; k<128; k++)
17254 {
17255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53888 times.
53888 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
17256 return qe_invalid;
17257 53888 }
17258
2/2
✓ Branch 0 taken 53888 times.
✓ Branch 1 taken 421 times.
54309 for(int32_t k=0; k<128; k++)
17259 {
17260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53888 times.
53888 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
17261 return qe_invalid;
17262 53888 }
17263
2/2
✓ Branch 0 taken 53888 times.
✓ Branch 1 taken 421 times.
54309 for(int32_t k=0; k<128; k++)
17264 {
17265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53888 times.
53888 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
17266 return qe_invalid;
17267 53888 }
17268 421 }
17269
2/2
✓ Branch 0 taken 2945 times.
✓ Branch 1 taken 3128 times.
6073 if(scr_has_flags & SCRHAS_COMBOFLAG)
17270 {
17271
2/2
✓ Branch 0 taken 550528 times.
✓ Branch 1 taken 3128 times.
553656 for(int32_t k=0; k<176; ++k)
17272 {
17273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 550528 times.
550528 if(!p_igetw(&(temp_mapscr->data[k]),f))
17274 return qe_invalid;
17275 550528 }
17276
2/2
✓ Branch 0 taken 550528 times.
✓ Branch 1 taken 3128 times.
553656 for(int32_t k=0; k<176; ++k)
17277 {
17278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 550528 times.
550528 if(!p_getc(&(temp_mapscr->sflag[k]),f))
17279 return qe_invalid;
17280 550528 }
17281
2/2
✓ Branch 0 taken 550528 times.
✓ Branch 1 taken 3128 times.
553656 for(int32_t k=0; k<176; ++k)
17282 {
17283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 550528 times.
550528 if(!p_getc(&(temp_mapscr->cset[k]),f))
17284 return qe_invalid;
17285 550528 }
17286 3128 }
17287
1/2
✓ Branch 0 taken 6073 times.
✗ Branch 1 not taken.
6073 if(scr_has_flags & SCRHAS_MISC)
17288 {
17289
1/2
✓ Branch 0 taken 6073 times.
✗ Branch 1 not taken.
6073 if(!p_igetw(&(temp_mapscr->color),f))
17290 return qe_invalid;
17291
1/2
✓ Branch 0 taken 6073 times.
✗ Branch 1 not taken.
6073 if(!p_getc(&(temp_mapscr->csensitive),f))
17292 return qe_invalid;
17293
1/2
✓ Branch 0 taken 6073 times.
✗ Branch 1 not taken.
6073 if(!p_getc(&(temp_mapscr->oceansfx),f))
17294 return qe_invalid;
17295
1/2
✓ Branch 0 taken 6073 times.
✗ Branch 1 not taken.
6073 if(!p_getc(&(temp_mapscr->bosssfx),f))
17296 return qe_invalid;
17297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6073 times.
6073 if(!p_getc(&(temp_mapscr->secretsfx),f))
17298 return qe_invalid;
17299
1/2
✓ Branch 0 taken 6073 times.
✗ Branch 1 not taken.
6073 if(!p_getc(&(temp_mapscr->holdupsfx),f))
17300 return qe_invalid;
17301
1/2
✓ Branch 0 taken 6073 times.
✗ Branch 1 not taken.
6073 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
17302 return qe_invalid;
17303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6073 times.
6073 if(!p_igetw(&(temp_mapscr->screen_midi),f))
17304 return qe_invalid;
17305
1/2
✓ Branch 0 taken 6073 times.
✗ Branch 1 not taken.
6073 if(!p_getc(&(temp_mapscr->lens_layer),f))
17306 return qe_invalid;
17307 6073 }
17308 else
17309 {
17310 temp_mapscr->screen_midi = -1;
17311 temp_mapscr->csensitive = 1;
17312 }
17313 //FFC
17314 6073 bool old_ff = version < 25;
17315 6073 dword bits = 0;
17316 6073 word numffc = 32;
17317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6073 times.
6073 if(old_ff)
17318 {
17319 if(!p_igetl(&bits,f))
17320 return qe_invalid;
17321 }
17322 else
17323 {
17324
1/2
✓ Branch 0 taken 6073 times.
✗ Branch 1 not taken.
6073 if(!p_igetw(&numffc,f))
17325 return qe_invalid;
17326 }
17327 byte tempbyte;
17328 word tempw;
17329
4/6
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 6040 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
✓ Branch 4 taken 33 times.
✗ Branch 5 not taken.
6073 static ffcdata nil_ffc;
17330 6073 temp_mapscr->ffcCountMarkDirty();
17331
2/2
✓ Branch 0 taken 6073 times.
✓ Branch 1 taken 8316 times.
14389 for(word m = 0; m < numffc; ++m)
17332 {
17333
1/2
✓ Branch 0 taken 8316 times.
✗ Branch 1 not taken.
8316 ffcdata& tempffc = (m < MAXFFCS)
17334 8316 ? temp_mapscr->ffcs[m]
17335 : nil_ffc; //sanity
17336 8316 tempffc.clear();
17337
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8316 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8316 if(old_ff && !(bits & (1<<m))) continue;
17338
17339
1/2
✓ Branch 0 taken 8316 times.
✗ Branch 1 not taken.
8316 if(!p_igetw(&tempw,f))
17340 return qe_invalid;
17341
3/4
✓ Branch 0 taken 8316 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1546 times.
✓ Branch 3 taken 6770 times.
8316 if(!old_ff && !tempw) //empty ffc, nothing more to load
17342 6770 continue;
17343 1546 tempffc.setData(tempw);
17344
17345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1546 times.
1546 if(!p_getc(&(tempffc.cset),f))
17346 return qe_invalid;
17347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1546 times.
1546 if(!p_igetw(&(tempffc.delay),f))
17348 return qe_invalid;
17349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1546 times.
1546 if(!p_igetzf(&(tempffc.x),f))
17350 return qe_invalid;
17351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1546 times.
1546 if(!p_igetzf(&(tempffc.y),f))
17352 return qe_invalid;
17353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1546 times.
1546 if(!p_igetzf(&(tempffc.vx),f))
17354 return qe_invalid;
17355
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1546 times.
1546 if(!p_igetzf(&(tempffc.vy),f))
17356 return qe_invalid;
17357
1/2
✓ Branch 0 taken 1546 times.
✗ Branch 1 not taken.
1546 if(!p_igetzf(&(tempffc.ax),f))
17358 return qe_invalid;
17359
1/2
✓ Branch 0 taken 1546 times.
✗ Branch 1 not taken.
1546 if(!p_igetzf(&(tempffc.ay),f))
17360 return qe_invalid;
17361
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1546 times.
1546 if(!p_getc(&(tempffc.link),f))
17362 return qe_invalid;
17363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1546 times.
1546 if(version < 24)
17364 {
17365 if(!p_getc(&tempbyte,f))
17366 return qe_invalid;
17367 tempffc.hit_width = (tempbyte&0x3F)+1;
17368 tempffc.txsz = (tempbyte>>6)+1;
17369 if(!p_getc(&tempbyte,f))
17370 return qe_invalid;
17371 tempffc.hit_height = (tempbyte&0x3F)+1;
17372 tempffc.tysz = (tempbyte>>6)+1;
17373 }
17374 else
17375 {
17376
1/2
✓ Branch 0 taken 1546 times.
✗ Branch 1 not taken.
1546 if(!p_igetl(&(tempffc.hit_width),f))
17377 return qe_invalid;
17378
1/2
✓ Branch 0 taken 1546 times.
✗ Branch 1 not taken.
1546 if(!p_igetl(&(tempffc.hit_height),f))
17379 return qe_invalid;
17380
1/2
✓ Branch 0 taken 1546 times.
✗ Branch 1 not taken.
1546 if(!p_getc(&(tempffc.txsz),f))
17381 return qe_invalid;
17382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1546 times.
1546 if(!p_getc(&(tempffc.tysz),f))
17383 return qe_invalid;
17384 }
17385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1546 times.
1546 if(!p_igetl(&(tempffc.flags),f))
17386 return qe_invalid;
17387 1546 tempffc.updateSolid();
17388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1546 times.
1546 if(!p_igetw(&(tempffc.script),f))
17389 return qe_invalid;
17390
2/2
✓ Branch 0 taken 12368 times.
✓ Branch 1 taken 1546 times.
13914 for(auto q = 0; q < 8; ++q)
17391 {
17392
1/2
✓ Branch 0 taken 12368 times.
✗ Branch 1 not taken.
12368 if(!p_igetl(&(tempffc.initd[q]),f))
17393 return qe_invalid;
17394 12368 }
17395
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1546 times.
1546 if(!p_getc(&(tempbyte),f))
17396 return qe_invalid;
17397 1546 tempffc.inita[0]=tempbyte*10000;
17398
17399
1/2
✓ Branch 0 taken 1546 times.
✗ Branch 1 not taken.
1546 if(!p_getc(&(tempbyte),f))
17400 return qe_invalid;
17401 1546 tempffc.inita[1]=tempbyte*10000;
17402 1546 }
17403
2/2
✓ Branch 0 taken 769028 times.
✓ Branch 1 taken 6073 times.
775101 for(word m = numffc; m < MAXFFCS; ++m)
17404 {
17405 769028 temp_mapscr->ffcs[m].clear();
17406 769028 }
17407 //END FFC
17408 }
17409 253249 return 0;
17410 263632 }
17411
17412
17413 129 int32_t readmaps(PACKFILE *f, zquestheader *Header)
17414 {
17415 129 int32_t scr=0;
17416
17417 129 word version=0;
17418 dword dummy;
17419 int32_t screens_to_read;
17420
17421 129 mapscr temp_mapscr;
17422 zcmap temp_map;
17423 word temp_map_count;
17424 dword section_size;
17425
17426
3/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17427 {
17428 4 screens_to_read=MAPSCRS192b136;
17429 4 }
17430 else
17431 {
17432 125 screens_to_read=MAPSCRS;
17433 }
17434
17435
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(Header->zelda_version > 0x192)
17436 {
17437 //section version info
17438
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&version,f))
17439 {
17440 return qe_invalid;
17441 }
17442
17443 125 FFCore.quest_format[vMaps] = version;
17444
17445 //al_trace("Maps version %d\n", version);
17446
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&dummy,f))
17447 {
17448 return qe_invalid;
17449 }
17450
17451 //section size
17452
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&section_size,f))
17453 {
17454 return qe_invalid;
17455 }
17456
17457 //finally... section data
17458
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&temp_map_count,f))
17459 {
17460 return 5;
17461 }
17462 125 }
17463 else
17464 {
17465 4 temp_map_count=map_count;
17466 }
17467
17468
2/4
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 129 times.
129 if (!(temp_map_count >= 0 && temp_map_count <= MAXMAPS2))
17469 {
17470 return qe_invalid;
17471 }
17472
17473 129 const int32_t _mapsSize = MAPSCRS*temp_map_count;
17474 129 TheMaps.resize(_mapsSize);
17475 129 map_autolayers.clear();
17476 129 map_autolayers.resize(temp_map_count*6);
17477
17478
2/2
✓ Branch 0 taken 264792 times.
✓ Branch 1 taken 129 times.
264921 for(int32_t i(0); i<_mapsSize; i++)
17479 264792 TheMaps[i].zero_memory();
17480
17481 129 memset(ZCMaps, 0, sizeof(zcmap)*MAXMAPS2);
17482
17483 129 temp_mapscr.zero_memory();
17484
17485 { //Is this stuff even needed anymore? Is it used at all? -Em
17486 129 memset(&temp_map, 0, sizeof(zcmap));
17487 129 temp_map.scrResWidth = 256;
17488 129 temp_map.scrResHeight = 224;
17489 129 temp_map.tileWidth = 16;
17490 129 temp_map.tileHeight = 11;
17491 129 temp_map.viewWidth = 256;
17492 129 temp_map.viewHeight = 176;
17493 129 temp_map.viewX = 0;
17494 129 temp_map.viewY = 64;
17495 129 temp_map.subaWidth = 256;
17496 129 temp_map.subaHeight = 168;
17497 129 temp_map.subaTrans = false;
17498 129 temp_map.subpWidth = 256;
17499 129 temp_map.subpHeight = 56;
17500 129 temp_map.subpTrans = false;
17501 }
17502
4/4
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 1947 times.
✓ Branch 2 taken 1947 times.
✓ Branch 3 taken 129 times.
2076 for(int32_t i=0; i<temp_map_count && i<MAXMAPS2; i++)
17503 {
17504 //!TODO Trim fully
17505 1947 memcpy(&ZCMaps[i], &temp_map, sizeof(zcmap));
17506
17507 1947 byte valid=1;
17508
2/2
✓ Branch 0 taken 1819 times.
✓ Branch 1 taken 128 times.
1947 if(version > 22)
17509 {
17510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(!p_getc(&valid,f))
17511 return qe_invalid;
17512 128 }
17513
4/4
✓ Branch 0 taken 1940 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 1902 times.
✓ Branch 3 taken 38 times.
1947 if(valid && version > 25)
17514 {
17515
2/2
✓ Branch 0 taken 228 times.
✓ Branch 1 taken 38 times.
266 for(int q = 0; q < 6; ++q)
17516 {
17517
1/2
✓ Branch 0 taken 228 times.
✗ Branch 1 not taken.
228 if(!p_igetw(&map_autolayers[i*6+q],f))
17518 return qe_invalid;
17519 228 }
17520 38 }
17521
2/2
✓ Branch 0 taken 264584 times.
✓ Branch 1 taken 1947 times.
266531 for(int32_t j=0; j<screens_to_read; j++)
17522 {
17523 264584 scr=i*MAPSCRS+j;
17524 264584 clear_screen(&temp_mapscr);
17525
2/2
✓ Branch 0 taken 952 times.
✓ Branch 1 taken 263632 times.
264584 if(valid)
17526 263632 readmapscreen(f, Header, &temp_mapscr, &temp_map, version, scr);
17527
17528 264584 TheMaps[scr] = temp_mapscr;
17529 264584 }
17530
17531
3/6
✓ Branch 0 taken 1895 times.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1895 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1947 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17532 {
17533 52 int32_t index = (i*MAPSCRS+132);
17534
17535 52 TheMaps[index]=TheMaps[index-1];
17536
17537 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].data, TheMaps[i*MAPSCRS+131].data);
17538 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].sflag, TheMaps[i*MAPSCRS+131].sflag);
17539 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].cset, TheMaps[i*MAPSCRS+131].cset);
17540
17541
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 52 times.
208 for(int32_t j=133; j<MAPSCRS; j++)
17542 {
17543 156 scr=i*MAPSCRS+j;
17544
17545 156 TheMaps[scr].zero_memory();
17546 156 TheMaps[scr].valid = mVERSION;
17547 156 TheMaps[scr].screen_midi = -1;
17548 156 TheMaps[scr].csensitive = 1;
17549 156 }
17550 52 }
17551
17552
3/6
✓ Branch 0 taken 1895 times.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1895 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1947 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
17553 {
17554
2/2
✓ Branch 0 taken 7072 times.
✓ Branch 1 taken 52 times.
7124 for(int32_t j=0; j<MAPSCRS; j++)
17555 {
17556 7072 scr=i*MAPSCRS+j;
17557 7072 TheMaps[scr].door_combo_set=MakeDoors(i, j);
17558
17559
2/2
✓ Branch 0 taken 905216 times.
✓ Branch 1 taken 7072 times.
912288 for(int32_t k=0; k<128; k++)
17560 {
17561 905216 TheMaps[scr].secretcset[k]=tcmbcset2(i, TheMaps[scr].secretcombo[k]);
17562 905216 TheMaps[scr].secretflag[k]=tcmbflag2(i, TheMaps[scr].secretcombo[k]);
17563 905216 TheMaps[scr].secretcombo[k]=tcmbdat2(i, j, TheMaps[scr].secretcombo[k]);
17564 905216 }
17565 7072 }
17566 52 }
17567 1947 }
17568 129 map_count = temp_map_count;
17569 129 clear_screen(&temp_mapscr);
17570 129 return 0;
17571 129 }
17572
17573
17574 1094437 void update_combo(newcombo& cmb, word section_version)
17575 {
17576
2/2
✓ Branch 0 taken 153720 times.
✓ Branch 1 taken 940717 times.
1094437 if(section_version < 40)
17577 {
17578
3/3
✓ Branch 0 taken 1389 times.
✓ Branch 1 taken 14209 times.
✓ Branch 2 taken 925119 times.
940717 switch(cmb.type)
17579 {
17580 case cWATER: case cSHALLOWWATER:
17581 14209 cmb.attribytes[6] = iwRipples;
17582 14209 break;
17583 case cTALLGRASS: case cTALLGRASSNEXT: case cTALLGRASSTOUCHY:
17584 1389 cmb.attribytes[6] = iwTallGrass;
17585 1389 break;
17586 }
17587 940717 }
17588 1094437 }
17589 95 int32_t readcombos_old(word section_version, PACKFILE *f, zquestheader *, word version, word build, word start_combo, word max_combos)
17590 {
17591 95 reset_combo_animations();
17592 95 reset_combo_animations2();
17593
17594 95 init_combo_classes();
17595
17596 // combos
17597 95 word combos_used=0;
17598 int32_t dummy;
17599 byte padding;
17600 95 newcombo temp_combo;
17601 //word section_cversion=0;
17602
17603
2/2
✓ Branch 0 taken 6201600 times.
✓ Branch 1 taken 95 times.
6201695 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
17604
1/2
✓ Branch 0 taken 6201600 times.
✗ Branch 1 not taken.
6201600 combobuf[q].clear();
17605
17606 // if(version > 0x192)
17607 // {
17608 // //section version info
17609 // if(!p_igetw(&section_version,f))
17610 // {
17611 // return qe_invalid;
17612 // }
17613
17614 // FFCore.quest_format[vCombos] = section_version;
17615
17616 // //al_trace("Combos version %d\n", section_version);
17617 // if(!p_igetw(&section_cversion,f))
17618 // {
17619 // return qe_invalid;
17620 // }
17621
17622 // //section size
17623 // if(!p_igetl(&dummy,f))
17624 // {
17625 // return qe_invalid;
17626 // }
17627 // }
17628
17629
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95 times.
95 if(version < 0x174)
17630 {
17631 combos_used=1024;
17632 }
17633
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 4 times.
95 else if(version < 0x191)
17634 {
17635 4 combos_used=2048;
17636 4 }
17637 else
17638 {
17639
2/4
✓ Branch 0 taken 91 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 91 times.
✗ Branch 3 not taken.
91 if(!p_igetw(&combos_used,f))
17640 {
17641 return qe_invalid;
17642 }
17643 }
17644
17645 //finally... section data
17646
2/2
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 873209 times.
873304 for(int32_t i=0; i<combos_used; i++)
17647 {
17648
1/2
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
873209 temp_combo.clear();
17649
17650
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if ( section_version >= 11 )
17651 {
17652
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.tile,f))
17653 {
17654 return qe_invalid;
17655 }
17656 68884 }
17657 else
17658 {
17659
2/4
✓ Branch 0 taken 804325 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 804325 times.
✗ Branch 3 not taken.
804325 if(!p_igetw(&temp_combo.tile,f))
17660 {
17661 return qe_invalid;
17662 }
17663 }
17664 873209 temp_combo.o_tile = temp_combo.tile;
17665
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(!p_getc(&temp_combo.flip,f))
17666 {
17667 return qe_invalid;
17668 }
17669
17670
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(!p_getc(&temp_combo.walk,f))
17671 {
17672 return qe_invalid;
17673 }
17674
17675
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(!p_getc(&temp_combo.type,f))
17676 {
17677 return qe_invalid;
17678 }
17679
17680
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(!p_getc(&temp_combo.csets,f))
17681 {
17682 return qe_invalid;
17683 }
17684
17685
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 865017 times.
873209 if(version < 0x193)
17686 {
17687
2/4
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8192 times.
✗ Branch 3 not taken.
8192 if(!p_getc(&padding,f))
17688 return qe_invalid;
17689
17690
2/4
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8192 times.
✗ Branch 3 not taken.
8192 if(!p_getc(&padding,f))
17691 return qe_invalid;
17692
17693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8192 times.
8192 if(version < 0x192)
17694 {
17695
1/2
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
8192 if(version == 0x191)
17696 {
17697 for(int32_t tmpcounter=0; tmpcounter<16; tmpcounter++)
17698 {
17699 if(!p_getc(&padding,f))
17700 return qe_invalid;
17701 }
17702 }
17703 8192 }
17704 8192 }
17705
2/2
✓ Branch 0 taken 865017 times.
✓ Branch 1 taken 8192 times.
873209 if(version >= 0x192)
17706 {
17707
2/4
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865017 times.
✗ Branch 3 not taken.
865017 if(!p_getc(&temp_combo.frames,f))
17708 return qe_invalid;
17709
17710
2/4
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865017 times.
✗ Branch 3 not taken.
865017 if(!p_getc(&temp_combo.speed,f))
17711 return qe_invalid;
17712
17713
2/4
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865017 times.
✗ Branch 3 not taken.
865017 if(!p_igetw(&temp_combo.nextcombo,f))
17714 return qe_invalid;
17715
17716
2/4
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865017 times.
✗ Branch 3 not taken.
865017 if(!p_getc(&temp_combo.nextcset,f))
17717 return qe_invalid;
17718
17719 //Base flag
17720
2/2
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 465834 times.
865017 if(section_version>=3)
17721
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_getc(&temp_combo.flag,f))
17722 return qe_invalid;
17723
17724
2/2
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 465834 times.
865017 if(section_version>=4)
17725 {
17726
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_getc(&temp_combo.skipanim,f))
17727 return qe_invalid;
17728
17729
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_igetw(&temp_combo.nexttimer,f))
17730 return qe_invalid;
17731 399183 }
17732
17733
2/2
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 465834 times.
865017 if(section_version>=5)
17734
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_getc(&temp_combo.skipanimy,f))
17735 return qe_invalid;
17736
17737
2/2
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 465834 times.
865017 if(section_version>=6)
17738 {
17739
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_getc(&temp_combo.animflags,f))
17740 return qe_invalid;
17741
17742
1/2
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
399183 if(section_version == 6)
17743 temp_combo.animflags = temp_combo.animflags ? AF_FRESH : 0;
17744 399183 }
17745
17746
2/2
✓ Branch 0 taken 796133 times.
✓ Branch 1 taken 68884 times.
865017 if(section_version>=8) //combo Attributes[4] and userflags.
17747 {
17748
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 275536 times.
344420 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17749
2/4
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275536 times.
✗ Branch 3 not taken.
275536 if(!p_igetl(&temp_combo.attributes[q],f))
17750 return qe_invalid;
17751
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.usrflags,f))
17752 return qe_invalid;
17753
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(section_version >= 20)
17754
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetw(&temp_combo.genflags,f))
17755 return qe_invalid;
17756 68884 }
17757
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version>=10) //combo trigger flags
17758 {
17759
2/2
✓ Branch 0 taken 206652 times.
✓ Branch 1 taken 68884 times.
275536 for ( int32_t q = 0; q < 3; q++ )
17760
2/4
✓ Branch 0 taken 206652 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 206652 times.
✗ Branch 3 not taken.
206652 if(!p_igetl(&temp_combo.triggerflags[q],f))
17761 return qe_invalid;
17762 68884 }
17763
1/2
✓ Branch 0 taken 796133 times.
✗ Branch 1 not taken.
796133 else if(section_version==9) //combo trigger flags, V9 only had two indices of triggerflags[]
17764 {
17765 for ( int32_t q = 0; q < 2; q++ )
17766 if(!p_igetl(&temp_combo.triggerflags[q],f))
17767 return qe_invalid;
17768 }
17769
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version >= 9)
17770
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.triggerlevel,f))
17771 return qe_invalid;
17772
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version >= 22)
17773
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_getc(&temp_combo.triggerbtn,f))
17774 return qe_invalid;
17775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 24)
17776 {
17777 if(!p_getc(&temp_combo.triggeritem,f))
17778 return qe_invalid;
17779 if(!p_getc(&temp_combo.trigtimer,f))
17780 return qe_invalid;
17781 }
17782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 25)
17783 if(!p_getc(&temp_combo.trigsfx,f))
17784 return qe_invalid;
17785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 27)
17786 if(!p_igetl(&temp_combo.trigchange,f))
17787 return qe_invalid;
17788
17789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 29)
17790 {
17791 if(!p_igetw(&temp_combo.trigprox,f))
17792 return qe_invalid;
17793 if(!p_getc(&temp_combo.trigctr,f))
17794 return qe_invalid;
17795 if(!p_igetl(&temp_combo.trigctramnt,f))
17796 return qe_invalid;
17797 }
17798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 30)
17799 if(!p_getc(&temp_combo.triglbeam,f))
17800 return qe_invalid;
17801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 31)
17802 {
17803 if(!p_getc(&temp_combo.trigcschange,f))
17804 return qe_invalid;
17805 if(!p_igetw(&temp_combo.spawnitem,f))
17806 return qe_invalid;
17807 if(!p_igetw(&temp_combo.spawnenemy,f))
17808 return qe_invalid;
17809 if(!p_getc(&temp_combo.exstate,f))
17810 return qe_invalid;
17811 if(!p_igetl(&temp_combo.spawnip,f))
17812 return qe_invalid;
17813 if(!p_getc(&temp_combo.trigcopycat,f))
17814 return qe_invalid;
17815 }
17816
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 32)
17817 if(!p_getc(&temp_combo.trigcooldown,f))
17818 return qe_invalid;
17819
17820
2/2
✓ Branch 0 taken 796133 times.
✓ Branch 1 taken 68884 times.
865017 if(section_version>=12) //combo label
17821 {
17822 char label[12];
17823 68884 label[11] = '\0';
17824
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 757724 times.
826608 for ( int32_t q = 0; q < 11; q++ )
17825
2/4
✓ Branch 0 taken 757724 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 757724 times.
✗ Branch 3 not taken.
757724 if(!p_getc(&label[q],f))
17826 return qe_invalid;
17827
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 temp_combo.label = label;
17828 68884 }
17829
2/2
✓ Branch 0 taken 796133 times.
✓ Branch 1 taken 68884 times.
865017 if(section_version>=13) //attribytes[4]
17830
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 0; q < 4; q++ )
17831
2/4
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275536 times.
✗ Branch 3 not taken.
275536 if(!p_getc(&temp_combo.attribytes[q],f))
17832 68884 return qe_invalid;
17833 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
17834 * This fixes a poor implementation of a ->next flag bug thing.
17835 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
17836 * there was a version bump a few weeks before a change that broke stuff.
17837 */
17838
3/4
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 68884 times.
865017 if (section_version >= 13 && section_version < 21)
17839 {
17840 set_qr(qr_BUGGY_BUGGY_SLASH_TRIGGERS,1);
17841 }
17842 //combo scripts
17843
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version>=14)
17844 {
17845
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetw(&temp_combo.script,f))
17846 return qe_invalid;
17847
2/2
✓ Branch 0 taken 137768 times.
✓ Branch 1 taken 68884 times.
206652 for ( int32_t q = 0; q < 2; q++ )
17848
2/4
✓ Branch 0 taken 137768 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 137768 times.
✗ Branch 3 not taken.
137768 if(!p_igetl(&temp_combo.initd[q],f))
17849 return qe_invalid;
17850 68884 }
17851 //al_trace("Read combo script data\n");
17852
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version>=15)
17853 {
17854
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.o_tile,f)) return qe_invalid;
17855
2/2
✓ Branch 0 taken 37028 times.
✓ Branch 1 taken 31856 times.
68884 if(!temp_combo.o_tile) temp_combo.o_tile = temp_combo.tile;
17856
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_getc(&temp_combo.cur_frame,f)) return qe_invalid;
17857
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_getc(&temp_combo.aclk,f)) return qe_invalid;
17858 68884 }
17859
2/2
✓ Branch 0 taken 796133 times.
✓ Branch 1 taken 68884 times.
865017 if(section_version>=17) //attribytes[4]
17860 {
17861
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
17862
2/4
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275536 times.
✗ Branch 3 not taken.
275536 if(!p_getc(&temp_combo.attribytes[q],f))
17863 return qe_invalid;
17864
2/2
✓ Branch 0 taken 551072 times.
✓ Branch 1 taken 68884 times.
619956 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
17865
2/4
✓ Branch 0 taken 551072 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 551072 times.
✗ Branch 3 not taken.
551072 if(!p_igetw(&temp_combo.attrishorts[q],f))
17866 return qe_invalid;
17867 68884 }
17868
17869
1/2
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
865017 if(version < 0x193)
17870 for(int32_t q=0; q<11; q++)
17871 if(!p_getc(&dummy,f))
17872 return qe_invalid;
17873 865017 }
17874
17875 //Goriya tiles were flipped around in 2.11 build 7. Compensate for the flip here. -DD
17876
3/6
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 474026 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 399183 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
873209 if((version < 0x211)||((version == 0x211)&&(build<7)))
17877 {
17878
3/4
✓ Branch 0 taken 474026 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 465834 times.
✓ Branch 3 taken 8192 times.
474026 if(!get_qr(qr_NEWENEMYTILES))
17879 {
17880
1/5
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
8192 switch(temp_combo.tile)
17881 {
17882 case 130:
17883 temp_combo.tile = 132;
17884 break;
17885
17886 case 131:
17887 temp_combo.tile = 133;
17888 break;
17889
17890 case 132:
17891 temp_combo.tile = 130;
17892 break;
17893
17894 case 133:
17895 temp_combo.tile = 131;
17896 break;
17897 }
17898 8192 }
17899 474026 }
17900
17901
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if(section_version < 15)
17902 804325 temp_combo.o_tile = temp_combo.tile;
17903
17904
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if(section_version<18) //upper bits for .walk
17905 804325 temp_combo.walk |= 0xF0;
17906
17907
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if(section_version < 19)
17908
2/2
✓ Branch 0 taken 3217300 times.
✓ Branch 1 taken 804325 times.
4021625 for(int32_t q = 0; q < 4; ++q)
17909 4021625 temp_combo.attributes[q] *= 10000L;
17910
17911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 23)
17912 {
17913
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 872825 times.
873209 switch(temp_combo.type) //combotriggerCMBTYPEFX now required for combotype-specific effects
17914 {
17915 case cSCRIPT1: case cSCRIPT2: case cSCRIPT3: case cSCRIPT4: case cSCRIPT5:
17916 case cSCRIPT6: case cSCRIPT7: case cSCRIPT8: case cSCRIPT9: case cSCRIPT10:
17917 case cTRIGGERGENERIC: case cCSWITCH:
17918 384 temp_combo.triggerflags[0] |= combotriggerCMBTYPEFX;
17919 384 }
17920 873209 }
17921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 25)
17922 {
17923
2/2
✓ Branch 0 taken 3061 times.
✓ Branch 1 taken 870148 times.
873209 switch(temp_combo.type)
17924 {
17925 case cLOCKBLOCK: case cBOSSLOCKBLOCK:
17926
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3061 times.
3061 if(!(temp_combo.usrflags & cflag3))
17927 3061 temp_combo.attribytes[3] = WAV_DOOR;
17928 3061 temp_combo.usrflags &= ~cflag3;
17929 3061 break;
17930 }
17931 873209 }
17932
17933
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 26)
17934
2/2
✓ Branch 0 taken 872622 times.
✓ Branch 1 taken 587 times.
873796 if(temp_combo.type == cARMOS)
17935
1/2
✓ Branch 0 taken 587 times.
✗ Branch 1 not taken.
587 if(temp_combo.usrflags & cflag1)
17936 temp_combo.usrflags |= cflag3;
17937
17938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 27)
17939 {
17940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(temp_combo.triggerflags[0] & 0x00040000) //'next'
17941 temp_combo.trigchange = 1;
17942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 else if(temp_combo.triggerflags[0] & 0x00080000) //'prev'
17943 temp_combo.trigchange = -1;
17944 873209 else temp_combo.trigchange = 0;
17945 873209 temp_combo.triggerflags[0] &= ~(0x00040000|0x00080000);
17946 873209 }
17947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 28)
17948 {
17949
2/2
✓ Branch 0 taken 1689 times.
✓ Branch 1 taken 871520 times.
873209 switch(temp_combo.type)
17950 {
17951 case cLOCKBLOCK: case cLOCKEDCHEST:
17952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1689 times.
1689 if(temp_combo.usrflags & cflag7)
17953 temp_combo.usrflags |= cflag8;
17954 1689 else temp_combo.usrflags &= ~cflag8;
17955 1689 temp_combo.usrflags &= ~cflag7;
17956 1689 break;
17957 }
17958
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 873140 times.
873209 switch(temp_combo.type)
17959 {
17960 case cCHEST: case cLOCKEDCHEST: case cBOSSCHEST:
17961 69 temp_combo.attrishorts[2] = -1;
17962 69 temp_combo.usrflags |= cflag7;
17963 69 break;
17964 }
17965 873209 }
17966
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if(section_version < 20)
17967 {
17968 804325 temp_combo.genflags = 0;
17969
2/2
✓ Branch 0 taken 19291 times.
✓ Branch 1 taken 785034 times.
804325 switch(temp_combo.type)
17970 {
17971 case cPUSH_WAIT: case cPUSH_HEAVY:
17972 case cPUSH_HW: case cL_STATUE:
17973 case cR_STATUE: case cPUSH_HEAVY2:
17974 case cPUSH_HW2: case cPOUND:
17975 case cC_STATUE: case cMIRROR:
17976 case cMIRRORSLASH: case cMIRRORBACKSLASH:
17977 case cMAGICPRISM: case cMAGICPRISM4:
17978 case cMAGICSPONGE: case cEYEBALL_A:
17979 case cEYEBALL_B: case cEYEBALL_4:
17980 case cBUSH: case cFLOWERS:
17981 case cLOCKBLOCK: case cLOCKBLOCK2:
17982 case cBOSSLOCKBLOCK: case cBOSSLOCKBLOCK2:
17983 case cCHEST: case cCHEST2:
17984 case cLOCKEDCHEST: case cLOCKEDCHEST2:
17985 case cBOSSCHEST: case cBOSSCHEST2:
17986 case cBUSHNEXT: case cBUSHTOUCHY:
17987 case cFLOWERSTOUCHY: case cBUSHNEXTTOUCHY:
17988 case cSIGNPOST: case cCSWITCHBLOCK:
17989 case cTORCH: case cTRIGGERGENERIC:
17990
1/2
✓ Branch 0 taken 19291 times.
✗ Branch 1 not taken.
19291 if(temp_combo.usrflags & cflag16)
17991 {
17992 temp_combo.genflags |= cflag1;
17993 temp_combo.usrflags &= ~cflag16;
17994 }
17995 19291 break;
17996 }
17997 804325 }
17998
17999 873209 update_combo(temp_combo, section_version);
18000
18001
1/2
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
873209 if(i>=start_combo)
18002 {
18003
1/2
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
873209 combobuf[i] = temp_combo;
18004 873209 }
18005 873209 }
18006
18007
3/6
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 91 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
95 if((version < 0x192)|| ((version == 0x192)&&(build<185)))
18008 {
18009
2/2
✓ Branch 0 taken 261120 times.
✓ Branch 1 taken 4 times.
261124 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18010 {
18011
1/2
✓ Branch 0 taken 261120 times.
✗ Branch 1 not taken.
261120 if(combobuf[tmpcounter].type==cHOOKSHOTONLY)
18012 {
18013 combobuf[tmpcounter].type=cLADDERHOOKSHOT;
18014 }
18015 261120 }
18016 4 }
18017
18018 //June 3 2012; ladder only is broken in 2.10 and allows the hookshot also. -Gleeok
18019
4/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 83 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
95 if(version == 0x210 && !is_zquest())
18020 {
18021
2/2
✓ Branch 0 taken 783360 times.
✓ Branch 1 taken 12 times.
783372 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18022
2/2
✓ Branch 0 taken 783351 times.
✓ Branch 1 taken 9 times.
783369 if(combobuf[tmpcounter].type == cLADDERONLY)
18023 9 combobuf[tmpcounter].type = cLADDERHOOKSHOT;
18024 12 }
18025
18026
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 16 times.
95 if(section_version<7)
18027 {
18028
2/2
✓ Branch 0 taken 1044480 times.
✓ Branch 1 taken 16 times.
1044496 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18029 {
18030
6/9
✓ Branch 0 taken 250 times.
✓ Branch 1 taken 174 times.
✓ Branch 2 taken 126 times.
✓ Branch 3 taken 45 times.
✓ Branch 4 taken 45 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1043840 times.
1044480 switch(combobuf[tmpcounter].type)
18031 {
18032 case cSLASH:
18033 250 combobuf[tmpcounter].type=cSLASHTOUCHY;
18034 250 break;
18035
18036 case cSLASHITEM:
18037 174 combobuf[tmpcounter].type=cSLASHITEMTOUCHY;
18038 174 break;
18039
18040 case cBUSH:
18041 126 combobuf[tmpcounter].type=cBUSHTOUCHY;
18042 126 break;
18043
18044 case cFLOWERS:
18045 45 combobuf[tmpcounter].type=cFLOWERSTOUCHY;
18046 45 break;
18047
18048 case cTALLGRASS:
18049 45 combobuf[tmpcounter].type=cTALLGRASSTOUCHY;
18050 45 break;
18051
18052 case cSLASHNEXT:
18053 combobuf[tmpcounter].type=cSLASHNEXTTOUCHY;
18054 break;
18055
18056 case cSLASHNEXTITEM:
18057 combobuf[tmpcounter].type=cSLASHNEXTITEMTOUCHY;
18058 break;
18059
18060 case cBUSHNEXT:
18061 combobuf[tmpcounter].type=cBUSHNEXTTOUCHY;
18062 break;
18063 }
18064 1044480 }
18065 16 }
18066
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 93 times.
95 if (section_version < 16)
18067 {
18068
2/2
✓ Branch 0 taken 6071040 times.
✓ Branch 1 taken 93 times.
6071133 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18069 {
18070
2/2
✓ Branch 0 taken 6062986 times.
✓ Branch 1 taken 8054 times.
6071040 if (combobuf[tmpcounter].type == cWATER)
18071 {
18072 8054 combobuf[tmpcounter].attributes[0] = 40000L;
18073 8054 }
18074 6071040 }
18075 93 }
18076
3/4
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✓ Branch 3 taken 1 times.
95 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
18077 {
18078 1 combobuf[0].walk = 0xF0;
18079 1 combobuf[0].type = 0;
18080 1 combobuf[0].flag = 0;
18081 1 }
18082
18083 //Now for the new combo alias reset
18084
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 16 times.
95 if(section_version<2)
18085 {
18086
2/2
✓ Branch 0 taken 131072 times.
✓ Branch 1 taken 16 times.
131088 for(int32_t j=0; j<MAXCOMBOALIASES; j++)
18087 {
18088 131072 combo_aliases[j].width = 0;
18089 131072 combo_aliases[j].height = 0;
18090 131072 combo_aliases[j].layermask = 0;
18091
18092
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131072 times.
131072 if(combo_aliases[j].combos != NULL)
18093 {
18094
1/2
✓ Branch 0 taken 131072 times.
✗ Branch 1 not taken.
131072 delete[] combo_aliases[j].combos;
18095 131072 }
18096
18097
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131072 times.
131072 if(combo_aliases[j].csets != NULL)
18098 {
18099
1/2
✓ Branch 0 taken 131072 times.
✗ Branch 1 not taken.
131072 delete[] combo_aliases[j].csets;
18100 131072 }
18101
18102
1/2
✓ Branch 0 taken 131072 times.
✗ Branch 1 not taken.
131072 combo_aliases[j].combos = new word[1];
18103
1/2
✓ Branch 0 taken 131072 times.
✗ Branch 1 not taken.
131072 combo_aliases[j].csets = new byte[1];
18104 131072 combo_aliases[j].combos[0] = 0;
18105 131072 combo_aliases[j].csets[0] = 0;
18106 131072 }
18107 16 }
18108
18109
18110
1/2
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
95 setup_combo_animations();
18111
1/2
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
95 setup_combo_animations2();
18112 95 return 0;
18113 95 }
18114 221228 int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
18115 {
18116 byte combo_has_flags;
18117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 221228 times.
221228 if(!p_getc(&combo_has_flags,f))
18118 return qe_invalid;
18119
18120 221228 temp_combo.clear();
18121
2/2
✓ Branch 0 taken 144925 times.
✓ Branch 1 taken 76303 times.
221228 if(combo_has_flags)
18122 {
18123
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 76300 times.
76303 if(combo_has_flags&CHAS_BASIC)
18124 {
18125
1/2
✓ Branch 0 taken 76300 times.
✗ Branch 1 not taken.
76300 if(!p_igetl(&temp_combo.tile,f))
18126 {
18127 return qe_invalid;
18128 }
18129 76300 temp_combo.o_tile = temp_combo.tile;
18130
18131
1/2
✓ Branch 0 taken 76300 times.
✗ Branch 1 not taken.
76300 if(!p_getc(&temp_combo.flip,f))
18132 {
18133 return qe_invalid;
18134 }
18135
18136
1/2
✓ Branch 0 taken 76300 times.
✗ Branch 1 not taken.
76300 if(!p_getc(&temp_combo.walk,f))
18137 {
18138 return qe_invalid;
18139 }
18140
18141
1/2
✓ Branch 0 taken 76300 times.
✗ Branch 1 not taken.
76300 if(!p_getc(&temp_combo.type,f))
18142 {
18143 return qe_invalid;
18144 }
18145
18146
1/2
✓ Branch 0 taken 76300 times.
✗ Branch 1 not taken.
76300 if(!p_getc(&temp_combo.flag,f))
18147 {
18148 return qe_invalid;
18149 }
18150
18151
1/2
✓ Branch 0 taken 76300 times.
✗ Branch 1 not taken.
76300 if(!p_getc(&temp_combo.csets,f))
18152 {
18153 return qe_invalid;
18154 }
18155 76300 }
18156
2/2
✓ Branch 0 taken 76280 times.
✓ Branch 1 taken 23 times.
76303 if(combo_has_flags&CHAS_SCRIPT)
18157 {
18158
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 15 times.
23 if (s_version>=41)
18159 {
18160 8 p_getcstr(&temp_combo.label, f);
18161 8 }
18162 else
18163 {
18164 char label[12];
18165 15 label[11] = '\0';
18166
2/2
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 15 times.
180 for ( int32_t q = 0; q < 11; q++ )
18167 {
18168
1/2
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
165 if(!p_getc(&label[q],f))
18169 {
18170 return qe_invalid;
18171 }
18172 165 }
18173 15 temp_combo.label = label;
18174 }
18175
18176
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetw(&temp_combo.script,f)) return qe_invalid;
18177
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 23 times.
69 for ( int32_t q = 0; q < 2; q++ )
18178 {
18179
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if(!p_igetl(&temp_combo.initd[q],f))
18180 {
18181 return qe_invalid;
18182 }
18183 46 }
18184 23 }
18185
2/2
✓ Branch 0 taken 56050 times.
✓ Branch 1 taken 20253 times.
76303 if(combo_has_flags&CHAS_ANIM)
18186 {
18187
1/2
✓ Branch 0 taken 20253 times.
✗ Branch 1 not taken.
20253 if(!p_getc(&temp_combo.frames,f))
18188 {
18189 return qe_invalid;
18190 }
18191
18192
1/2
✓ Branch 0 taken 20253 times.
✗ Branch 1 not taken.
20253 if(!p_getc(&temp_combo.speed,f))
18193 {
18194 return qe_invalid;
18195 }
18196
18197
1/2
✓ Branch 0 taken 20253 times.
✗ Branch 1 not taken.
20253 if(!p_igetw(&temp_combo.nextcombo,f))
18198 {
18199 return qe_invalid;
18200 }
18201
18202
1/2
✓ Branch 0 taken 20253 times.
✗ Branch 1 not taken.
20253 if(!p_getc(&temp_combo.nextcset,f))
18203 {
18204 return qe_invalid;
18205 }
18206
18207
1/2
✓ Branch 0 taken 20253 times.
✗ Branch 1 not taken.
20253 if(!p_getc(&temp_combo.skipanim,f))
18208 {
18209 return qe_invalid;
18210 }
18211
18212
1/2
✓ Branch 0 taken 20253 times.
✗ Branch 1 not taken.
20253 if(!p_getc(&temp_combo.skipanimy,f))
18213 {
18214 return qe_invalid;
18215 }
18216
18217
1/2
✓ Branch 0 taken 20253 times.
✗ Branch 1 not taken.
20253 if(!p_getc(&temp_combo.animflags,f))
18218 {
18219 return qe_invalid;
18220 }
18221 20253 }
18222
2/2
✓ Branch 0 taken 65991 times.
✓ Branch 1 taken 10312 times.
76303 if(combo_has_flags&CHAS_ATTRIB)
18223 {
18224
2/2
✓ Branch 0 taken 41248 times.
✓ Branch 1 taken 10312 times.
51560 for ( int32_t q = 0; q < 4; q++ )
18225 {
18226
1/2
✓ Branch 0 taken 41248 times.
✗ Branch 1 not taken.
41248 if(!p_igetl(&temp_combo.attributes[q],f))
18227 {
18228 return qe_invalid;
18229 }
18230 41248 }
18231
2/2
✓ Branch 0 taken 82496 times.
✓ Branch 1 taken 10312 times.
92808 for ( int32_t q = 0; q < 8; q++ )
18232 {
18233
1/2
✓ Branch 0 taken 82496 times.
✗ Branch 1 not taken.
82496 if(!p_getc(&temp_combo.attribytes[q],f))
18234 {
18235 return qe_invalid;
18236 }
18237 82496 }
18238
2/2
✓ Branch 0 taken 82496 times.
✓ Branch 1 taken 10312 times.
92808 for ( int32_t q = 0; q < 8; q++ )
18239 {
18240
1/2
✓ Branch 0 taken 82496 times.
✗ Branch 1 not taken.
82496 if(!p_igetw(&temp_combo.attrishorts[q],f))
18241 {
18242 return qe_invalid;
18243 }
18244 82496 }
18245 10312 }
18246
2/2
✓ Branch 0 taken 74121 times.
✓ Branch 1 taken 2182 times.
76303 if(combo_has_flags&CHAS_FLAG)
18247 {
18248
1/2
✓ Branch 0 taken 2182 times.
✗ Branch 1 not taken.
2182 if(!p_igetl(&temp_combo.usrflags,f))
18249 {
18250 return qe_invalid;
18251 }
18252
1/2
✓ Branch 0 taken 2182 times.
✗ Branch 1 not taken.
2182 if(!p_igetw(&temp_combo.genflags,f))
18253 {
18254 return qe_invalid;
18255 }
18256 2182 }
18257
2/2
✓ Branch 0 taken 75530 times.
✓ Branch 1 taken 773 times.
76303 if(combo_has_flags&CHAS_TRIG)
18258 {
18259 773 int numtrigs = s_version < 36 ? 3 : 6;
18260
2/2
✓ Branch 0 taken 4209 times.
✓ Branch 1 taken 773 times.
4982 for ( int32_t q = 0; q < numtrigs; q++ )
18261 {
18262
1/2
✓ Branch 0 taken 4209 times.
✗ Branch 1 not taken.
4209 if(!p_igetl(&temp_combo.triggerflags[q],f))
18263 {
18264 return qe_invalid;
18265 }
18266 4209 }
18267
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_igetl(&temp_combo.triggerlevel,f))
18268 {
18269 return qe_invalid;
18270 }
18271
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_getc(&temp_combo.triggerbtn,f))
18272 {
18273 return qe_invalid;
18274 }
18275
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_getc(&temp_combo.triggeritem,f))
18276 {
18277 return qe_invalid;
18278 }
18279
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_getc(&temp_combo.trigtimer,f))
18280 {
18281 return qe_invalid;
18282 }
18283
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_getc(&temp_combo.trigsfx,f))
18284 {
18285 return qe_invalid;
18286 }
18287
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_igetl(&temp_combo.trigchange,f))
18288 {
18289 return qe_invalid;
18290 }
18291
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_igetw(&temp_combo.trigprox,f))
18292 {
18293 return qe_invalid;
18294 }
18295
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_getc(&temp_combo.trigctr,f))
18296 {
18297 return qe_invalid;
18298 }
18299
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_igetl(&temp_combo.trigctramnt,f))
18300 {
18301 return qe_invalid;
18302 }
18303
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_getc(&temp_combo.triglbeam,f))
18304 {
18305 return qe_invalid;
18306 }
18307
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_getc(&temp_combo.trigcschange,f))
18308 {
18309 return qe_invalid;
18310 }
18311
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_igetw(&temp_combo.spawnitem,f))
18312 {
18313 return qe_invalid;
18314 }
18315
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_igetw(&temp_combo.spawnenemy,f))
18316 {
18317 return qe_invalid;
18318 }
18319
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_getc(&temp_combo.exstate,f))
18320 {
18321 return qe_invalid;
18322 }
18323
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_igetl(&temp_combo.spawnip,f))
18324 {
18325 return qe_invalid;
18326 }
18327
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_getc(&temp_combo.trigcopycat,f))
18328 {
18329 return qe_invalid;
18330 }
18331
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_getc(&temp_combo.trigcooldown,f))
18332 {
18333 return qe_invalid;
18334 }
18335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 773 times.
773 if(s_version >= 35)
18336 {
18337
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_igetw(&temp_combo.prompt_cid,f))
18338 {
18339 return qe_invalid;
18340 }
18341
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_getc(&temp_combo.prompt_cs,f))
18342 {
18343 return qe_invalid;
18344 }
18345
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_igetw(&temp_combo.prompt_x,f))
18346 {
18347 return qe_invalid;
18348 }
18349
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_igetw(&temp_combo.prompt_y,f))
18350 {
18351 return qe_invalid;
18352 }
18353 773 }
18354
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 630 times.
773 if(s_version >= 36)
18355 {
18356
1/2
✓ Branch 0 taken 630 times.
✗ Branch 1 not taken.
630 if(!p_getc(&temp_combo.trig_lstate,f))
18357 {
18358 return qe_invalid;
18359 }
18360
1/2
✓ Branch 0 taken 630 times.
✗ Branch 1 not taken.
630 if(!p_getc(&temp_combo.trig_gstate,f))
18361 {
18362 return qe_invalid;
18363 }
18364
1/2
✓ Branch 0 taken 630 times.
✗ Branch 1 not taken.
630 if(!p_igetl(&temp_combo.trig_statetime,f))
18365 {
18366 return qe_invalid;
18367 }
18368 630 }
18369
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 630 times.
773 if(s_version >= 37)
18370 {
18371
1/2
✓ Branch 0 taken 630 times.
✗ Branch 1 not taken.
630 if(!p_igetw(&temp_combo.trig_genscr,f))
18372 {
18373 return qe_invalid;
18374 }
18375 630 }
18376
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 556 times.
773 if(s_version >= 38)
18377 {
18378
1/2
✓ Branch 0 taken 556 times.
✗ Branch 1 not taken.
556 if(!p_getc(&temp_combo.trig_group,f))
18379 {
18380 return qe_invalid;
18381 }
18382
1/2
✓ Branch 0 taken 556 times.
✗ Branch 1 not taken.
556 if(!p_igetw(&temp_combo.trig_group_val,f))
18383 {
18384 return qe_invalid;
18385 }
18386 556 }
18387 773 }
18388
2/2
✓ Branch 0 taken 76160 times.
✓ Branch 1 taken 143 times.
76303 if(combo_has_flags&CHAS_LIFT)
18389 {
18390
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_igetw(&temp_combo.liftcmb,f))
18391 return qe_invalid;
18392
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&temp_combo.liftcs,f))
18393 return qe_invalid;
18394
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_igetw(&temp_combo.liftundercmb,f))
18395 return qe_invalid;
18396
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&temp_combo.liftundercs,f))
18397 return qe_invalid;
18398
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&temp_combo.liftdmg,f))
18399 return qe_invalid;
18400
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&temp_combo.liftlvl,f))
18401 return qe_invalid;
18402
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&temp_combo.liftitm,f))
18403 return qe_invalid;
18404
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&temp_combo.liftflags,f))
18405 return qe_invalid;
18406
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&temp_combo.liftgfx,f))
18407 return qe_invalid;
18408
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&temp_combo.liftsprite,f))
18409 return qe_invalid;
18410
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&temp_combo.liftsfx,f))
18411 return qe_invalid;
18412
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_igetw(&temp_combo.liftbreaksprite,f))
18413 return qe_invalid;
18414
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&temp_combo.liftbreaksfx,f))
18415 return qe_invalid;
18416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 143 times.
143 if(s_version >= 34)
18417 {
18418
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&temp_combo.lifthei,f))
18419 return qe_invalid;
18420
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&temp_combo.lifttime,f))
18421 return qe_invalid;
18422 143 }
18423
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 136 times.
143 if(s_version >= 39)
18424 {
18425
1/2
✓ Branch 0 taken 136 times.
✗ Branch 1 not taken.
136 if(!p_getc(&temp_combo.lift_parent_item,f))
18426 return qe_invalid;
18427 136 }
18428 143 }
18429
2/2
✓ Branch 0 taken 76211 times.
✓ Branch 1 taken 92 times.
76303 if(combo_has_flags&CHAS_GENERAL)
18430 {
18431
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&temp_combo.speed_mult,f))
18432 return qe_invalid;
18433
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&temp_combo.speed_div,f))
18434 return qe_invalid;
18435
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetzf(&temp_combo.speed_add,f))
18436 return qe_invalid;
18437
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 76 times.
92 if(s_version >= 42)
18438 {
18439
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_getc(&temp_combo.sfx_appear,f))
18440 return qe_invalid;
18441
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_getc(&temp_combo.sfx_disappear,f))
18442 return qe_invalid;
18443
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_getc(&temp_combo.sfx_loop,f))
18444 return qe_invalid;
18445
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_getc(&temp_combo.sfx_walking,f))
18446 return qe_invalid;
18447
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_getc(&temp_combo.sfx_standing,f))
18448 return qe_invalid;
18449
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_getc(&temp_combo.spr_appear,f))
18450 return qe_invalid;
18451
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_getc(&temp_combo.spr_disappear,f))
18452 return qe_invalid;
18453
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_getc(&temp_combo.spr_walking,f))
18454 return qe_invalid;
18455
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_getc(&temp_combo.spr_standing,f))
18456 return qe_invalid;
18457 76 }
18458 92 }
18459 76303 }
18460 221228 update_combo(temp_combo, s_version);
18461 221228 return 0;
18462 221228 }
18463 129 int32_t readcombos(PACKFILE *f, zquestheader *Header, word version, word build, word start_combo, word max_combos)
18464 {
18465 129 word section_version=0;
18466 129 word section_cversion=0;
18467 129 word combos_used=0;
18468 int32_t dummy;
18469 byte padding;
18470 129 newcombo temp_combo;
18471
18472
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 reset_combo_animations();
18473
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 reset_combo_animations2();
18474
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 init_combo_classes();
18475
18476
2/2
✓ Branch 0 taken 8421120 times.
✓ Branch 1 taken 129 times.
8421249 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
18477
1/2
✓ Branch 0 taken 8421120 times.
✗ Branch 1 not taken.
8421120 combobuf[q].clear();
18478
18479
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(version > 0x192) //Version info
18480 {
18481
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetw(&section_version,f))
18482 {
18483 return qe_invalid;
18484 }
18485 125 FFCore.quest_format[vCombos] = section_version;
18486
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetw(&section_cversion,f))
18487 {
18488 return qe_invalid;
18489 }
18490
18491 //section size
18492
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetl(&dummy,f))
18493 {
18494 return qe_invalid;
18495 }
18496 125 }
18497
18498
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 95 times.
129 if(section_version > 32) //Cleanup time!
18499 {
18500
2/4
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
34 if(!p_igetw(&combos_used,f))
18501 {
18502 return qe_invalid;
18503 }
18504
2/2
✓ Branch 0 taken 221228 times.
✓ Branch 1 taken 34 times.
221262 for(int32_t i=0; i<combos_used; i++)
18505 {
18506
1/2
✓ Branch 0 taken 221228 times.
✗ Branch 1 not taken.
221228 auto ret = readcombo_loop(f,section_version,temp_combo);
18507
1/2
✓ Branch 0 taken 221228 times.
✗ Branch 1 not taken.
221228 if(ret) return ret;
18508
1/2
✓ Branch 0 taken 221228 times.
✗ Branch 1 not taken.
221228 if(i>=start_combo)
18509
1/2
✓ Branch 0 taken 221228 times.
✗ Branch 1 not taken.
221228 combobuf[i] = temp_combo;
18510 221228 }
18511 34 }
18512 else //Call the old function for all old versions
18513 {
18514
1/2
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
95 auto ret = readcombos_old(section_version,f,Header,version,build,start_combo,max_combos);
18515
1/2
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
95 if(ret) return ret; //error, end read
18516 }
18517
18518
3/4
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✓ Branch 3 taken 33 times.
129 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
18519 {
18520 33 combobuf[0].walk = 0xF0;
18521 33 combobuf[0].type = 0;
18522 33 combobuf[0].flag = 0;
18523 33 }
18524
18525
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 setup_combo_animations();
18526
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 setup_combo_animations2();
18527 129 return 0;
18528 129 }
18529
18530 113 int32_t readcomboaliases(PACKFILE *f, zquestheader *Header, word version, word build)
18531 {
18532 //these are here to bypass compiler warnings about unused arguments
18533 113 Header=Header;
18534 113 version=version;
18535 113 build=build;
18536
18537 int32_t dummy;
18538 113 word sversion=0, c_sversion;
18539
18540 //section version info
18541
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(!p_igetw(&sversion,f))
18542 {
18543 return qe_invalid;
18544 }
18545
18546 113 FFCore.quest_format[vComboAliases] = sversion;
18547
18548 //al_trace("Combo aliases version %d\n", sversion);
18549
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&c_sversion,f))
18550 {
18551 return qe_invalid;
18552 }
18553
18554 //section size
18555
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetl(&dummy,f))
18556 {
18557 return qe_invalid;
18558 }
18559
18560 113 int32_t max_num_combo_aliases = MAXCOMBOALIASES;
18561
18562
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 77 times.
113 if(sversion < 3) // max saved combo alias' upped from 256 to 2048.
18563 {
18564 77 max_num_combo_aliases = MAX250COMBOALIASES;
18565 77 }
18566
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(sversion < 2) // max saved combo alias' upped from 256 to 2048.
18567 {
18568 max_num_combo_aliases = OLDMAXCOMBOALIASES;
18569 }
18570
18571
2/2
✓ Branch 0 taken 452608 times.
✓ Branch 1 taken 113 times.
452721 for(int32_t j=0; j<max_num_combo_aliases; j++)
18572 {
18573 byte width,height,mask,tempcset;
18574 int32_t count;
18575 word tempword;
18576 byte tempbyte;
18577
18578
1/2
✓ Branch 0 taken 452608 times.
✗ Branch 1 not taken.
452608 if(!p_igetw(&tempword,f))
18579 {
18580 return qe_invalid;
18581 }
18582
18583 452608 combo_aliases[j].combo = tempword;
18584
18585
1/2
✓ Branch 0 taken 452608 times.
✗ Branch 1 not taken.
452608 if(!p_getc(&tempbyte,f))
18586 {
18587 return qe_invalid;
18588 }
18589
18590 452608 combo_aliases[j].cset = tempbyte;
18591
18592
1/2
✓ Branch 0 taken 452608 times.
✗ Branch 1 not taken.
452608 if(!p_getc(&width,f))
18593 {
18594 return qe_invalid;
18595 }
18596
18597
1/2
✓ Branch 0 taken 452608 times.
✗ Branch 1 not taken.
452608 if(!p_getc(&height,f))
18598 {
18599 return qe_invalid;
18600 }
18601
18602
1/2
✓ Branch 0 taken 452608 times.
✗ Branch 1 not taken.
452608 if(!p_getc(&mask,f))
18603 {
18604 return qe_invalid;
18605 }
18606
18607 452608 count=(width+1)*(height+1)*(comboa_lmasktotal(mask)+1);
18608
18609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 452608 times.
452608 if(combo_aliases[j].combos != NULL)
18610 {
18611
1/2
✓ Branch 0 taken 452608 times.
✗ Branch 1 not taken.
452608 delete[] combo_aliases[j].combos;
18612 452608 }
18613
18614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 452608 times.
452608 if(combo_aliases[j].csets != NULL)
18615 {
18616
1/2
✓ Branch 0 taken 452608 times.
✗ Branch 1 not taken.
452608 delete[] combo_aliases[j].csets;
18617 452608 }
18618
18619 452608 combo_aliases[j].width = width;
18620 452608 combo_aliases[j].height = height;
18621 452608 combo_aliases[j].layermask = mask;
18622 452608 combo_aliases[j].combos = new word[count];
18623 452608 combo_aliases[j].csets = new byte[count];
18624
18625
2/2
✓ Branch 0 taken 463821 times.
✓ Branch 1 taken 452608 times.
916429 for(int32_t k=0; k<count; k++)
18626 {
18627
1/2
✓ Branch 0 taken 463821 times.
✗ Branch 1 not taken.
463821 if(!p_igetw(&tempword,f))
18628 {
18629 return qe_invalid;
18630 }
18631
18632 463821 combo_aliases[j].combos[k] = tempword;
18633 463821 }
18634
18635
2/2
✓ Branch 0 taken 463821 times.
✓ Branch 1 taken 452608 times.
916429 for(int32_t k=0; k<count; k++)
18636 {
18637
1/2
✓ Branch 0 taken 463821 times.
✗ Branch 1 not taken.
463821 if(!p_getc(&tempcset,f))
18638 {
18639 return qe_invalid;
18640 }
18641
18642 463821 combo_aliases[j].csets[k] = tempcset;
18643 463821 }
18644 452608 }
18645
18646 113 word num_combo_pools = 0;
18647
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 34 times.
113 if(sversion >= 4)
18648 {
18649
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 if(!p_igetw(&num_combo_pools,f))
18650 {
18651 return qe_invalid;
18652 }
18653 34 }
18654
18655
2/2
✓ Branch 0 taken 925696 times.
✓ Branch 1 taken 113 times.
925809 for(combo_pool& pool : combo_pools)
18656 {
18657 925696 pool.clear();
18658 }
18659
18660 113 combo_pool temp_cpool;
18661
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 113 times.
206 for(word cp = 0; cp < num_combo_pools; ++cp)
18662 {
18663 93 int32_t num_combos_in_pool = 0;
18664
2/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
93 if(!p_igetl(&num_combos_in_pool,f))
18665 {
18666 return qe_invalid;
18667 }
18668
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if(num_combos_in_pool < 1) continue; //nothing to read
18669
18670
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 temp_cpool.clear();
18671
18672 int32_t cp_cid; int8_t cp_cs; word cp_quant;
18673
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 403 times.
496 for(auto q = 0; q < num_combos_in_pool; ++q)
18674 {
18675
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_igetl(&cp_cid,f))
18676 {
18677 return qe_invalid;
18678 }
18679
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_getc(&cp_cs,f))
18680 {
18681 return qe_invalid;
18682 }
18683
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_igetw(&cp_quant,f))
18684 {
18685 return qe_invalid;
18686 }
18687
1/2
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
403 temp_cpool.add(cp_cid, cp_cs, cp_quant);
18688 403 }
18689
18690
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 combo_pools[cp] = temp_cpool;
18691 93 }
18692
18693 113 return 0;
18694 113 }
18695
18696 129 int32_t readcolordata(PACKFILE *f, miscQdata *Misc, word version, word build, word start_cset, word max_csets)
18697 {
18698 //these are here to bypass compiler warnings about unused arguments
18699
18700 //THE *48 REFERS TO EACH CSET BEING 16 COLORS with 3 VALUES OF RGB (3*16 is 48)
18701 //Capitalized cause it'll save you a headache. -Deedee
18702 129 start_cset=start_cset;
18703 129 max_csets=max_csets;
18704 129 word s_version=0;
18705
18706 miscQdata temp_misc;
18707 129 memcpy(&temp_misc, Misc, sizeof(temp_misc));
18708
18709 byte temp_colordata[48];
18710 char temp_palname[PALNAMESIZE];
18711
18712 int32_t dummy;
18713 word palcycles;
18714
18715
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(version > 0x192)
18716 {
18717 //section version info
18718
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_version,f))
18719 {
18720 return qe_invalid;
18721 }
18722
18723 125 FFCore.quest_format[vCSets] = s_version;
18724
18725 //al_trace("Color data version %d\n", s_version);
18726
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&dummy,f))
18727 {
18728 return qe_invalid;
18729 }
18730
18731 //section size
18732
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&dummy,f))
18733 {
18734 return qe_invalid;
18735 }
18736 125 }
18737
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 36 times.
129 if (s_version < 5)
18738 {
18739
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 89 times.
✓ Branch 2 taken 89 times.
✗ Branch 3 not taken.
93 bool RealOldVerion = ((version < 0x192)||((version == 0x192)&&(build<73)));
18740
18741 //finally... section data
18742 93 int32_t q = 0;
18743 93 int32_t p = -15;
18744
2/2
✓ Branch 0 taken 22320 times.
✓ Branch 1 taken 93 times.
22413 for(int32_t i=0; i<oldpdTOTAL; ++i)
18745 {
18746 22320 memset(temp_colordata, 0, 48);
18747
18748
1/2
✓ Branch 0 taken 22320 times.
✗ Branch 1 not taken.
22320 if(!pfread(temp_colordata,48,f))
18749 {
18750 return qe_invalid;
18751 }
18752
18753 22320 memcpy(&colordata[q*48], temp_colordata, 48);
18754
18755 22320 ++q;
18756
8/8
✓ Branch 0 taken 20832 times.
✓ Branch 1 taken 1488 times.
✓ Branch 2 taken 1581 times.
✓ Branch 3 taken 19251 times.
✓ Branch 4 taken 186 times.
✓ Branch 5 taken 1395 times.
✓ Branch 6 taken 8 times.
✓ Branch 7 taken 178 times.
22320 if (p > 0 && (p%13)==12 && (i < oldpoSPRITE || !RealOldVerion)) //It's > 0 instead of >= 0 because it should append
18757 {
18758
1/2
✓ Branch 0 taken 1573 times.
✗ Branch 1 not taken.
1573 if (s_version < 5) //Bumping up the size of level palettes
18759 {
18760 1573 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18761 1573 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18762 1573 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18763 1573 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18764 1573 q+=4;
18765 1573 }
18766 else
18767 {
18768 for(int m = 0; m < 4; ++m)
18769 {
18770 memset(temp_colordata, 0, 48);
18771 if(!pfread(temp_colordata,48,f))
18772 {
18773 return qe_invalid;
18774 }
18775 memcpy(&colordata[q*48], temp_colordata, 48);
18776 ++q;
18777 }
18778 }
18779 1573 }
18780 22320 ++p;
18781 22320 }
18782
18783
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 89 times.
93 if(RealOldVerion)
18784 {
18785 4 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18786 4 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18787 4 memcpy(colordata+((poSPRITE255+11)*48), colordata+((poSPRITE255+10)*48), 48);
18788 4 memcpy(colordata+((poSPRITE255+10)*48), colordata+((poSPRITE255+9)*48), 48);
18789 4 memcpy(colordata+((poSPRITE255+9)*48), colordata+((poSPRITE255+8)*48), 48);
18790 4 memset(colordata+((poSPRITE255+8)*48), 0, 48);
18791 4 }
18792 else
18793 {
18794 89 memset(temp_colordata, 0, 48);
18795
18796
2/2
✓ Branch 0 taken 278837 times.
✓ Branch 1 taken 89 times.
278926 for(int32_t i=0; i<newpdTOTAL-oldpdTOTAL; ++i)
18797 {
18798
1/2
✓ Branch 0 taken 278837 times.
✗ Branch 1 not taken.
278837 if(!pfread(temp_colordata,48,f))
18799 {
18800 return qe_invalid;
18801 }
18802
18803 278837 memcpy(&colordata[q*48], temp_colordata, 48);
18804
18805 278837 ++q;
18806
7/8
✓ Branch 0 taken 278837 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21449 times.
✓ Branch 3 taken 257388 times.
✓ Branch 4 taken 178 times.
✓ Branch 5 taken 21271 times.
✓ Branch 6 taken 154 times.
✓ Branch 7 taken 24 times.
278837 if (p > 0 && (p%13)==12 && (i < (newpoSPRITE-oldpdTOTAL) || (s_version >= 4))) //It's > 0 instead of >= 0 because it should append
18807 {
18808
1/2
✓ Branch 0 taken 21425 times.
✗ Branch 1 not taken.
21425 if (s_version < 5) //Bumping up the size of level palettes
18809 {
18810 21425 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18811 21425 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18812 21425 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18813 21425 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18814 21425 q+=4;
18815 21425 }
18816 else
18817 {
18818 for(int m = 0; m < 4; ++m)
18819 {
18820 memset(temp_colordata, 0, 48);
18821 if(!pfread(temp_colordata,48,f))
18822 {
18823 return qe_invalid;
18824 }
18825 memcpy(&colordata[q*48], temp_colordata, 48);
18826 ++q;
18827 }
18828 }
18829 21425 }
18830 278837 ++p;
18831 278837 }
18832
18833
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 77 times.
89 if(s_version < 4)
18834 {
18835 12 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18836 12 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18837 12 }
18838 else
18839 {
18840
2/2
✓ Branch 0 taken 256256 times.
✓ Branch 1 taken 77 times.
256333 for(int32_t i=0; i<newerpdTOTAL-newpdTOTAL; ++i)
18841 {
18842
1/2
✓ Branch 0 taken 256256 times.
✗ Branch 1 not taken.
256256 if(!pfread(temp_colordata,48,f))
18843 {
18844 return qe_invalid;
18845 }
18846
18847 256256 memcpy(&colordata[q*48], temp_colordata, 48);
18848 256256 ++q;
18849
5/6
✓ Branch 0 taken 256256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19712 times.
✓ Branch 3 taken 236544 times.
✓ Branch 4 taken 154 times.
✓ Branch 5 taken 19558 times.
256256 if (p > 0 && (p%13)==12 && i < newerpoSPRITE-newpdTOTAL) //It's > 0 instead of >= 0 because it should append
18850 {
18851
1/2
✓ Branch 0 taken 19558 times.
✗ Branch 1 not taken.
19558 if (s_version < 5) //Bumping up the size of level palettes
18852 {
18853 19558 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18854 19558 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18855 19558 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18856 19558 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18857 19558 q+=4;
18858 19558 }
18859 else
18860 {
18861 for(int m = 0; m < 4; ++m)
18862 {
18863 memset(temp_colordata, 0, 48);
18864 if(!pfread(temp_colordata,48,f))
18865 {
18866 return qe_invalid;
18867 }
18868 memcpy(&colordata[q*48], temp_colordata, 48);
18869 ++q;
18870 }
18871 }
18872 19558 }
18873 256256 ++p;
18874 256256 }
18875
18876 //By this point, q should be about equal to pdTOTAL255. If it isn't, I've fucked up. -Deedee
18877 }
18878 }
18879 93 }
18880 else
18881 {
18882
2/2
✓ Branch 0 taken 314964 times.
✓ Branch 1 taken 36 times.
315000 for(int32_t i=0; i<pdTOTAL255; ++i)
18883 {
18884 314964 memset(temp_colordata, 0, 48);
18885
18886
1/2
✓ Branch 0 taken 314964 times.
✗ Branch 1 not taken.
314964 if(!pfread(temp_colordata,48,f))
18887 {
18888 return qe_invalid;
18889 }
18890
18891 314964 memcpy(&colordata[i*48], temp_colordata, 48);
18892 314964 }
18893 }
18894
18895
3/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((version < 0x192)||((version == 0x192)&&(build<76)))
18896 {
18897 4 init_palnames();
18898 4 }
18899 else
18900 {
18901 125 int32_t palnamestoread = 0;
18902
18903
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 113 times.
125 if(s_version < 3)
18904 12 palnamestoread = OLDMAXLEVELS;
18905 else
18906 113 palnamestoread = 512;
18907
18908
2/2
✓ Branch 0 taken 60928 times.
✓ Branch 1 taken 125 times.
61053 for(int32_t i=0; i<palnamestoread; ++i)
18909 {
18910 60928 memset(temp_palname, 0, PALNAMESIZE);
18911
18912
1/2
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
60928 if(!pfread(temp_palname,PALNAMESIZE,f))
18913 {
18914 return qe_invalid;
18915 }
18916
18917 60928 memcpy(palnames[i], temp_palname, PALNAMESIZE);
18918 60928 }
18919
18920
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 125 times.
3197 for(int32_t i=palnamestoread; i<MAXLEVELS; i++)
18921 {
18922 3072 memset(palnames[i], 0, PALNAMESIZE);
18923 3072 }
18924 }
18925
18926
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(version > 0x192)
18927 {
18928
2/2
✓ Branch 0 taken 32000 times.
✓ Branch 1 taken 125 times.
32125 for(int32_t i=0; i<256; i++)
18929 {
18930
2/2
✓ Branch 0 taken 96000 times.
✓ Branch 1 taken 32000 times.
128000 for(int32_t j=0; j<3; j++)
18931 {
18932 96000 temp_misc.cycles[i][j].first=0;
18933 96000 temp_misc.cycles[i][j].count=0;
18934 96000 temp_misc.cycles[i][j].speed=0;
18935 96000 }
18936 32000 }
18937
18938
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&palcycles,f))
18939 {
18940 return qe_invalid;
18941 }
18942
18943
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
125 if (!(palcycles >= 0 && palcycles <= NUM_PAL_CYCLES))
18944 {
18945 return qe_invalid;
18946 }
18947
18948
2/2
✓ Branch 0 taken 3576 times.
✓ Branch 1 taken 125 times.
3701 for(int32_t i=0; i<palcycles; i++)
18949 {
18950
2/2
✓ Branch 0 taken 10728 times.
✓ Branch 1 taken 3576 times.
14304 for(int32_t j=0; j<3; j++)
18951 {
18952
1/2
✓ Branch 0 taken 10728 times.
✗ Branch 1 not taken.
10728 if(!p_getc(&temp_misc.cycles[i][j].first,f))
18953 {
18954 return qe_invalid;
18955 }
18956 10728 }
18957
18958
2/2
✓ Branch 0 taken 10728 times.
✓ Branch 1 taken 3576 times.
14304 for(int32_t j=0; j<3; j++)
18959 {
18960
1/2
✓ Branch 0 taken 10728 times.
✗ Branch 1 not taken.
10728 if(!p_getc(&temp_misc.cycles[i][j].count,f))
18961 {
18962 return qe_invalid;
18963 }
18964 10728 }
18965
18966
2/2
✓ Branch 0 taken 10728 times.
✓ Branch 1 taken 3576 times.
14304 for(int32_t j=0; j<3; j++)
18967 {
18968
1/2
✓ Branch 0 taken 10728 times.
✗ Branch 1 not taken.
10728 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
18969 {
18970 return qe_invalid;
18971 }
18972 10728 }
18973 3576 }
18974
18975 125 memcpy(Misc, &temp_misc, sizeof(temp_misc));
18976 125 }
18977
18978 129 return 0;
18979 129 }
18980
18981 129 int32_t readtiles(PACKFILE *f, tiledata *buf, zquestheader *Header, word version, word build, word start_tile, int32_t max_tiles, bool from_init)
18982 {
18983 129 int32_t tiles_used=0;
18984 129 word section_version = 0;
18985 129 word section_cversion = 0;
18986 129 int32_t section_size= 0;
18987 129 byte *temp_tile = new byte[tilesize(tf32Bit)];
18988
18989 //Tile Expansion
18990 //if ( version >= 0x254 && build >= 41 )
18991
3/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 36 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93 times.
129 if (version < 0x254 && build < 41)
18992 {
18993 //al_trace("Build was < 41 when reading tiles\n");
18994 93 max_tiles = ZC250MAXTILES;
18995 93 }
18996
18997 //al_trace("Max Tiles: %d\n", max_tiles);
18998
18999
2/6
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 129 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if(Header!=NULL&&(!Header->data_flags[ZQ_TILES]&&!from_init)) //keep for old quests
19000 {
19001 if(!init_tiles(true, Header))
19002 {
19003 al_trace("Unable to initialize tiles\n");
19004 }
19005
19006 delete[] temp_tile;
19007 temp_tile=NULL;
19008 return 0;
19009 }
19010 else
19011 {
19012
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(version > 0x192)
19013 {
19014 //section version info
19015
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&section_version,f))
19016 {
19017 delete[] temp_tile;
19018 return qe_invalid;
19019 }
19020
19021 125 FFCore.quest_format[vTiles] = section_version;
19022
19023
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&section_cversion,f))
19024 {
19025 delete[] temp_tile;
19026 return qe_invalid;
19027 }
19028
19029 //section size
19030
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&section_size,f))
19031 {
19032 delete[] temp_tile;
19033 return qe_invalid;
19034 }
19035 125 }
19036
19037 //if ( build < 41 )
19038 //{
19039 // tiles_used = ZC250MAXTILES;
19040 //}
19041
19042
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(version < 0x174)
19043 {
19044 tiles_used=TILES_PER_PAGE*4;
19045 } //no expanded tile space
19046
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 else if(version < 0x191)
19047 {
19048 4 tiles_used=OLDMAXTILES;
19049 4 }
19050 else
19051 {
19052 //finally... section data
19053
3/4
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
125 if ( version >= 0x254 && build >= 41 ) //read and write the size of tiles_used properly
19054 {
19055
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tiles_used,f))
19056 {
19057 delete[] temp_tile;
19058 return qe_invalid;
19059 }
19060 36 }
19061 else
19062 {
19063
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 if(!p_igetw(&tiles_used,f))
19064 {
19065 delete[] temp_tile;
19066 return qe_invalid;
19067 }
19068 }
19069 }
19070
19071
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 tiles_used=zc_min(tiles_used, max_tiles);
19072
19073 //if ( version < 0x254 || ( version >= 0x254 && build < 41 )) //don't do this, it crashes ZQuest. -Z
19074 //if ( version < 0x254 && build < 41 )
19075
3/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if ( version < 0x254 || (version == 0x254 && build < 41) )
19076 //if ( build < 41 )
19077 {
19078
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 tiles_used=zc_min(tiles_used, ZC250MAXTILES-start_tile);
19079 93 }
19080 else //2.55
19081 {
19082
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 tiles_used = zc_min(tiles_used,NEWMAXTILES-start_tile);
19083 }
19084
19085 //if ( section_version > 1 ) tiles_used = NEWMAXTILES;
19086
19087 //al_trace("tiles_used = %d\n", tiles_used);
19088
19089
2/2
✓ Branch 0 taken 3496770 times.
✓ Branch 1 taken 129 times.
3496899 for(int32_t i=0; i<tiles_used; ++i)
19090 {
19091 3496770 byte format=tf4Bit;
19092 3496770 memset(temp_tile, 0, tilesize(tf32Bit));
19093
19094
3/6
✓ Branch 0 taken 630780 times.
✓ Branch 1 taken 2865990 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 630780 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3496770 if((version>0x211)||((version==0x211)&&(build>4)))
19095 {
19096
1/2
✓ Branch 0 taken 2865990 times.
✗ Branch 1 not taken.
2865990 if(!p_getc(&format,f))
19097 {
19098 delete[] temp_tile;
19099 return qe_invalid;
19100 }
19101 2865990 }
19102
4/4
✓ Branch 0 taken 1316436 times.
✓ Branch 1 taken 2180334 times.
✓ Branch 2 taken 612691 times.
✓ Branch 3 taken 703745 times.
3496770 if(section_version > 2 && !format)
19103 {
19104 703745 reset_tile(buf,start_tile+i,tf4Bit);
19105 703745 continue;
19106 }
19107
19108
1/2
✓ Branch 0 taken 2793025 times.
✗ Branch 1 not taken.
2793025 if(!pfread(temp_tile,tilesize(format),f))
19109 {
19110 delete[] temp_tile;
19111 return qe_invalid;
19112 }
19113
19114 2793025 buf[start_tile+i].format=format;
19115
19116
1/2
✓ Branch 0 taken 2793025 times.
✗ Branch 1 not taken.
2793025 if(buf[start_tile+i].data)
19117 {
19118 2793025 free(buf[start_tile+i].data);
19119 2793025 buf[start_tile+i].data=NULL;
19120 2793025 }
19121
19122 2793025 buf[start_tile+i].data=(byte *)malloc(tilesize(buf[start_tile+i].format));
19123 2793025 memcpy(buf[start_tile+i].data,temp_tile,tilesize(buf[start_tile+i].format));
19124 2793025 }
19125 }
19126
19127
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if ( section_version < 2 ) //write blank tile data --check s_version with this again instead?
19128 {
19129 //al_trace("Writing blank tile data to new tiles for build < 41\n");
19130
2/2
✓ Branch 0 taken 13855140 times.
✓ Branch 1 taken 93 times.
13855233 for ( int32_t q = ZC250MAXTILES; q < NEWMAXTILES; ++q )
19131 {
19132
19133 //memcpy(buf[q].data,temp_tile,tilesize(buf[q].format));
19134 13855140 reset_tile(buf,q,tf4Bit);
19135
19136
19137 /*
19138
19139 byte tempbyte;
19140 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19141 {
19142 tempbyte=buf[ZC250MAXTILES-1].data[i];
19143 buf[q].data[i] = tempbyte;
19144 }
19145 //int32_t temp = tempbyte=buf[130].data[i];
19146 //buf[q].data = buf[ZC250MAXTILES-1].data;
19147 */
19148 //reset_tile(buf,q,tf4Bit);
19149 13855140 }
19150
19151 93 }
19152
19153
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( version < 0x254 || ( version >= 0x254 && build < 41 ))
19154 {
19155
2/2
✓ Branch 0 taken 4121646 times.
✓ Branch 1 taken 93 times.
4121739 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19156 {
19157 //al_trace("Resetting tiles for ZC250MAXTILES, iteration: %d\n", i);
19158 4121646 reset_tile(buf,i,tf4Bit);
19159 4121646 }
19160 93 }
19161 else
19162 {
19163
2/2
✓ Branch 0 taken 6196944 times.
✓ Branch 1 taken 36 times.
6196980 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19164 {
19165 //al_trace("Resetting tiles for build 41+\n");
19166 6196944 reset_tile(buf,i,tf4Bit);
19167 6196944 }
19168 }
19169
19170
3/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((version < 0x192)|| ((version == 0x192)&&(build<186)))
19171 {
19172
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(get_qr(qr_BSZELDA)) //
19173 {
19174 byte tempbyte;
19175 int32_t floattile=wpnsbuf[iwSwim].tile;
19176
19177 for(int32_t i=0; i<tilesize(tf4Bit); i++) //BSZelda tiles are out of order //does this include swim tiles?
19178 {
19179 tempbyte=buf[23].data[i];
19180 buf[23].data[i]=buf[24].data[i];
19181 buf[24].data[i]=buf[25].data[i];
19182 buf[25].data[i]=buf[26].data[i];
19183 buf[26].data[i]=tempbyte;
19184 }
19185 //swim tiles are out of order, too, but nobody cared? -Z
19186 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19187 {
19188 tempbyte=buf[floattile+11].data[i];
19189 buf[floattile+11].data[i]=buf[floattile+12].data[i];
19190 buf[floattile+12].data[i]=tempbyte;
19191 }
19192 }
19193 4 }
19194
19195
3/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((version < 0x211)||((version == 0x211)&&(build<7))) //Goriya tiles are out of order
19196 {
19197
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
16 if(!get_qr(qr_NEWENEMYTILES))
19198 {
19199 byte tempbyte;
19200
19201
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 4 times.
516 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19202 {
19203 512 tempbyte=buf[130].data[i];
19204 512 buf[130].data[i]=buf[132].data[i];
19205 512 buf[132].data[i]=tempbyte;
19206
19207 512 tempbyte=buf[131].data[i];
19208 512 buf[131].data[i]=buf[133].data[i];
19209 512 buf[133].data[i]=tempbyte;
19210 512 }
19211 4 }
19212 16 }
19213
19214 129 al_trace("Registering blank tiles\n");
19215 129 register_blank_tiles();
19216
19217 //memset(temp_tile, 0, tilesize(tf32Bit));
19218
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 delete[] temp_tile;
19219 129 temp_tile=NULL;
19220 129 return 0;
19221 129 }
19222
19223 129 int32_t readtunes(PACKFILE *f, zquestheader *Header, zctune *tunes /*zcmidi_ *midis*/)
19224 {
19225 129 byte *mf=midi_flags;
19226 int32_t dummy;
19227 word dummy2;
19228 // zcmidi_ temp_midi;
19229 int32_t tunes_to_read;
19230 129 int32_t tune_count=0;
19231 129 word section_version=0;
19232 129 zctune temp;
19233
19234
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(Header->zelda_version < 0x193)
19235 {
19236 // mf=Header->data_flags+ZQ_MIDIS2;
19237
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<178)))
19238 {
19239 4 tunes_to_read=MAXCUSTOMMIDIS192b177;
19240 4 }
19241 else
19242 {
19243 tunes_to_read=MAXCUSTOMTUNES;
19244 }
19245 4 }
19246 else
19247 {
19248 //section version info
19249
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&section_version,f))
19250 {
19251 return qe_invalid;
19252 }
19253
19254 125 FFCore.quest_format[vMIDIs] = section_version;
19255
19256 //al_trace("Tunes version %d\n", section_version);
19257
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&dummy2,f))
19258 {
19259 return qe_invalid;
19260 }
19261
19262 //section size
19263
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&dummy,f))
19264 {
19265 return qe_invalid;
19266 }
19267
19268 //finally... section data
19269
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!pfread(midi_flags,sizeof(midi_flags),f))
19270 {
19271 return qe_invalid;
19272 }
19273
19274 125 tunes_to_read=MAXCUSTOMTUNES;
19275 }
19276
19277
2/2
✓ Branch 0 taken 32508 times.
✓ Branch 1 taken 129 times.
32637 for(int32_t i=0; i<MAXCUSTOMTUNES; ++i)
19278 {
19279
2/2
✓ Branch 0 taken 30206 times.
✓ Branch 1 taken 2302 times.
32508 if(get_bit(mf, i))
19280 {
19281 2302 ++tune_count;
19282 2302 }
19283 32508 }
19284
19285 129 reset_tunes(tunes); //reset_midis(midis);
19286
19287
2/2
✓ Branch 0 taken 31628 times.
✓ Branch 1 taken 129 times.
31757 for(int32_t i=0; i<tunes_to_read; i++)
19288 {
19289 31628 temp.clear(); //memset(&temp_midi,0,sizeof(zcmidi_));
19290
19291 31628 tunes[i].reset(); // reset_midi(midis+i);
19292
19293
2/2
✓ Branch 0 taken 29326 times.
✓ Branch 1 taken 2302 times.
31628 if(get_bit(mf,i))
19294 {
19295
2/2
✓ Branch 0 taken 717 times.
✓ Branch 1 taken 1585 times.
2302 if(section_version < 4)
19296 {
19297
1/2
✓ Branch 0 taken 717 times.
✗ Branch 1 not taken.
717 if(!pfread(&temp.title,sizeof(char)*20,f))
19298 {
19299 return qe_invalid;
19300 }
19301 717 }
19302 else
19303 {
19304
1/2
✓ Branch 0 taken 1585 times.
✗ Branch 1 not taken.
1585 if(!pfread(&temp.title,sizeof(temp.title),f))
19305 {
19306 return qe_invalid;
19307 }
19308 }
19309
19310
1/2
✓ Branch 0 taken 2302 times.
✗ Branch 1 not taken.
2302 if(!p_igetl(&temp.start,f))
19311 {
19312 return qe_invalid;
19313 }
19314
19315
1/2
✓ Branch 0 taken 2302 times.
✗ Branch 1 not taken.
2302 if(!p_igetl(&temp.loop_start,f))
19316 {
19317 return qe_invalid;
19318 }
19319
19320
1/2
✓ Branch 0 taken 2302 times.
✗ Branch 1 not taken.
2302 if(!p_igetl(&temp.loop_end,f))
19321 {
19322 return qe_invalid;
19323 }
19324
19325
1/2
✓ Branch 0 taken 2302 times.
✗ Branch 1 not taken.
2302 if(!p_igetw(&temp.loop,f))
19326 {
19327 return qe_invalid;
19328 }
19329
19330
1/2
✓ Branch 0 taken 2302 times.
✗ Branch 1 not taken.
2302 if(!p_igetw(&temp.volume,f))
19331 {
19332 return qe_invalid;
19333 }
19334
19335
2/2
✓ Branch 0 taken 2224 times.
✓ Branch 1 taken 78 times.
2302 if(Header->zelda_version < 0x193)
19336 {
19337
1/2
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
78 if(!p_igetl(&dummy,f))
19338 {
19339 return qe_invalid;
19340 }
19341 78 }
19342
19343
2/2
✓ Branch 0 taken 717 times.
✓ Branch 1 taken 1585 times.
2302 if(section_version >= 3)
19344 {
19345
1/2
✓ Branch 0 taken 1585 times.
✗ Branch 1 not taken.
1585 if(!pfread(&temp.flags,sizeof(temp.flags),f))
19346 {
19347 return qe_invalid;
19348 }
19349 1585 }
19350
19351 2302 tunes[i].copyfrom(temp); // memcpy(&midis[i], &temp_midi, sizeof(zcmidi_));
19352
19353
2/2
✓ Branch 0 taken 717 times.
✓ Branch 1 taken 1585 times.
2302 if(section_version < 2) //= 1 || (Header->zelda_version < 0x211) || (Header->zelda_version == 0x211 && Header->build < 18))
19354 {
19355 // old format - a midi is a midi
19356
1/2
✓ Branch 0 taken 717 times.
✗ Branch 1 not taken.
717 if((tunes[i].data=read_midi(f))==NULL)
19357 {
19358 return qe_invalid;
19359 }
19360
19361 //yes you can do this. Isn't the ? operator awesome? :)
19362 717 tunes[i].format = MFORMAT_MIDI;
19363 717 }
19364 else
19365 {
19366 // 'midi' could be midi or nes, gb, ... music
19367
1/2
✓ Branch 0 taken 1585 times.
✗ Branch 1 not taken.
1585 if(!pfread(&tunes[i].format,sizeof(tunes[i].format),f))
19368 {
19369 return qe_invalid;
19370 }
19371
19372 1585 zctune *ptr = &tunes[i];
19373
19374
1/2
✓ Branch 0 taken 1585 times.
✗ Branch 1 not taken.
1585 switch(temp.format)
19375 {
19376 case MFORMAT_MIDI:
19377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1585 times.
1585 if((ptr->data=read_midi(f))==NULL)
19378 {
19379 return qe_invalid;
19380 }
19381
19382 1585 break;
19383
19384 default:
19385 return qe_invalid;
19386 break;
19387 }
19388 }
19389 2302 }
19390 31628 }
19391
19392 129 return 0;
19393 129 }
19394
19395 129 int32_t readcheatcodes(PACKFILE *f, zquestheader *Header)
19396 {
19397 int32_t dummy;
19398 ZCHEATS tempzcheats;
19399 129 char temp_use_cheats=1;
19400 129 memset(&tempzcheats, 0, sizeof(tempzcheats));
19401 129 word s_version = 0;
19402
19403
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(Header->zelda_version > 0x192)
19404 {
19405 //section version info
19406
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_version,f))
19407 {
19408 return qe_invalid;
19409 }
19410
19411 125 FFCore.quest_format[vCheats] = s_version;
19412 //al_trace("Cheats version %d\n", dummy);
19413
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&dummy,f))
19414 {
19415 return qe_invalid;
19416 }
19417
19418 //section size
19419
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&dummy,f))
19420 {
19421 return qe_invalid;
19422 }
19423
19424 //finally... section data
19425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(!p_getc(&temp_use_cheats,f))
19426 {
19427 return qe_invalid;
19428 }
19429 125 }
19430
19431
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(Header->data_flags[ZQ_CHEATS2])
19432 {
19433
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(!p_igetl(&tempzcheats.flags,f))
19434 {
19435 return qe_invalid;
19436 }
19437
19438
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(!pfread(&tempzcheats.codes, sizeof(tempzcheats.codes),f))
19439 {
19440 return qe_invalid;
19441 }
19442 129 }
19443
19444 129 memcpy(&zcheats, &tempzcheats, sizeof(tempzcheats));
19445 129 Header->data_flags[ZQ_CHEATS2]=temp_use_cheats;
19446
19447 129 return 0;
19448 129 }
19449
19450 307 int32_t readinitdata(PACKFILE *f, zquestheader *Header)
19451 {
19452 int32_t dummy;
19453 307 word s_version=0, s_cversion=0;
19454 byte padding;
19455
19456 307 zinitdata temp_zinit;
19457
19458 // Legacy item properties (now integrated into itemdata)
19459 byte sword_hearts[4];
19460 byte beam_hearts[4];
19461 307 byte beam_percent=0;
19462 word beam_power[4];
19463 307 byte hookshot_length=99;
19464 307 byte hookshot_links=100;
19465 307 byte longshot_length=99;
19466 307 byte longshot_links=100;
19467 307 byte moving_fairy_hearts=3;
19468 307 byte moving_fairy_heart_percent=0;
19469 307 byte stationary_fairy_hearts=3;
19470 307 byte stationary_fairy_heart_percent=0;
19471 307 byte moving_fairy_magic=0;
19472 307 byte moving_fairy_magic_percent=0;
19473 307 byte stationary_fairy_magic=0;
19474 307 byte stationary_fairy_magic_percent=0;
19475 307 byte blue_potion_hearts=100;
19476 307 byte blue_potion_heart_percent=1;
19477 307 byte red_potion_hearts=100;
19478 307 byte red_potion_heart_percent=1;
19479 307 byte blue_potion_magic=100;
19480 307 byte blue_potion_magic_percent=1;
19481 307 byte red_potion_magic=100;
19482 307 byte red_potion_magic_percent=1;
19483
19484
2/2
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 178 times.
307 temp_zinit.subscreen_style=get_qr(qr_COOLSCROLL)?1:0;
19485
19486
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(Header->zelda_version > 0x192)
19487 {
19488 //section version info
19489
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetw(&s_version,f))
19490 {
19491 return qe_invalid;
19492 }
19493
19494 125 FFCore.quest_format[vInitData] = s_version;
19495
19496 //al_trace("Init data version %d\n", s_version);
19497
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetw(&s_cversion,f))
19498 {
19499 return qe_invalid;
19500 }
19501
19502 //section size
19503
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetl(&dummy,f))
19504 {
19505 return qe_invalid;
19506 }
19507 125 }
19508
19509 /* HIGHLY UNORTHODOX UPDATING THING, by L
19510 * This fixes quests made before revision 277 (such as the 'Lost Isle Build'),
19511 * where the speed of Pols Voice changed. It also coincided with V_INITDATA
19512 * changing from 13 to 14.
19513 */
19514
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version < 14)
19515 16 fixpolsvoice=true;
19516
19517 /* End highly unorthodox updating thing */
19518
19519
5/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 75 times.
✓ Branch 5 taken 38 times.
129 if(s_version >= 15 && get_bit(deprecated_rules, 27)) // The int16_t-lived rule, qr_JUMPHEROLAYER3
19520 38 temp_zinit.jump_hero_layer_threshold=0;
19521
19522
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 113 times.
129 if(s_version >= 10)
19523 {
19524 char temp;
19525
19526 //new-style items
19527
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 113 times.
29041 for(int32_t j=0; j<256; j++)
19528 {
19529
2/4
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 28928 times.
28928 if(!p_getc(&temp,f))
19530 return qe_invalid;
19531
19532 28928 temp_zinit.items[j] = (temp != 0);
19533 28928 }
19534 113 }
19535
19536
5/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 53 times.
✓ Branch 5 taken 53 times.
129 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>26)))
19537 {
19538 char temp;
19539
19540 //finally... section data
19541
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 53 times.
✓ Branch 3 taken 53 times.
178 if((Header->zelda_version > 0x192)||
19542 //new only
19543 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19544 {
19545 //OLD-style items... sigh
19546
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 113 times.
125 if(s_version < 10)
19547 {
19548
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19549 {
19550 return qe_invalid;
19551 }
19552
19553 12 temp_zinit.items[iRaft]=(temp != 0);
19554
19555
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19556 {
19557 return qe_invalid;
19558 }
19559
19560 12 temp_zinit.items[iLadder]=(temp != 0);
19561
19562
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19563 {
19564 return qe_invalid;
19565 }
19566
19567 12 temp_zinit.items[iBook]=(temp != 0);
19568
19569
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19570 {
19571 return qe_invalid;
19572 }
19573
19574 12 temp_zinit.items[iMKey]=(temp!=0);
19575
19576
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19577 {
19578 return qe_invalid;
19579 }
19580
19581 12 temp_zinit.items[iFlippers]=(temp != 0);
19582
19583
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19584 {
19585 return qe_invalid;
19586 }
19587
19588 12 temp_zinit.items[iBoots]=(temp!=0);
19589 12 }
19590 125 }
19591
19592
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 166 times.
178 if(s_version < 10)
19593 {
19594 char tempring, tempsword, tempshield, tempwallet, tempbracelet, tempamulet, tempbow;
19595
19596
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempring,f))
19597 {
19598 return qe_invalid;
19599 }
19600
19601
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempsword,f))
19602 {
19603 return qe_invalid;
19604 }
19605
19606
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempshield,f))
19607 {
19608 return qe_invalid;
19609 }
19610
19611
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempwallet,f))
19612 {
19613 return qe_invalid;
19614 }
19615
19616
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempbracelet,f))
19617 {
19618 return qe_invalid;
19619 }
19620
19621
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempamulet,f))
19622 {
19623 return qe_invalid;
19624 }
19625
19626
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempbow,f))
19627 {
19628 return qe_invalid;
19629 }
19630
19631 //old only
19632
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if((Header->zelda_version == 0x192)&&(Header->build<174))
19633 {
19634 tempring=(tempring)?(1<<(tempring-1)):0;
19635 tempsword=(tempsword)?(1<<(tempsword-1)):0;
19636 tempshield=(tempshield)?(1<<(tempshield-1)):0;
19637 tempwallet=(tempwallet)?(1<<(tempwallet-1)):0;
19638 tempbracelet=(tempbracelet)?(1<<(tempbracelet-1)):0;
19639 tempamulet=(tempamulet)?(1<<(tempamulet-1)):0;
19640 tempbow=(tempbow)?(1<<(tempbow-1)):0;
19641 }
19642
19643 //rings start at level 2... wtf
19644 //account for this -DD
19645 12 tempring <<= 1;
19646
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_ring, tempring);
19647
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_sword, tempsword);
19648
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_shield, tempshield);
19649
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, tempwallet);
19650 //bracelet ALSO starts at level 2 :-( -DD
19651 12 tempbracelet<<=1;
19652
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bracelet, tempbracelet);
19653
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_amulet, tempamulet);
19654
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bow, tempbow);
19655
19656 //new only
19657
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if((Header->zelda_version == 0x192)&&(Header->build>173))
19658 {
19659 for(int32_t q=0; q<32; q++)
19660 {
19661 if(!p_getc(&padding,f))
19662 {
19663 return qe_invalid;
19664 }
19665 }
19666 }
19667
19668 char tempcandle, tempboomerang, temparrow, tempwhistle;
19669
19670
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempcandle,f))
19671 {
19672 return qe_invalid;
19673 }
19674
19675
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempboomerang,f))
19676 {
19677 return qe_invalid;
19678 }
19679
19680
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temparrow,f))
19681 {
19682 return qe_invalid;
19683 }
19684
19685
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19686 {
19687 return qe_invalid;
19688 }
19689
19690
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_potion, temp);
19691
19692
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempwhistle,f))
19693 {
19694 return qe_invalid;
19695 }
19696
19697 //old only
19698
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if((Header->zelda_version == 0x192)&&(Header->build<174))
19699 {
19700 tempcandle=(tempcandle)?(1<<(tempcandle-1)):0;
19701 tempboomerang=(tempboomerang)?(1<<(tempboomerang-1)):0;
19702 temparrow=(temparrow)?(1<<(temparrow-1)):0;
19703 tempwhistle=(tempwhistle)?(1<<(tempwhistle-1)):0;
19704 }
19705
19706
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_candle, tempcandle);
19707
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_brang, tempboomerang);
19708
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_arrow, temparrow);
19709
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_whistle, tempwhistle);
19710 //What about the potion...?
19711
19712 12 }
19713
19714
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 89 times.
178 if(s_version < 29)
19715 {
19716 //Oh sure, stick these IN THE MIDDLE OF THE ITEMS, just to make me want
19717 //to jab out my eye...
19718
2/4
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89 times.
✗ Branch 3 not taken.
89 if(!p_getc(&padding,f))
19719 return qe_invalid;
19720 89 temp_zinit.bombs = padding;
19721
19722
2/4
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89 times.
✗ Branch 3 not taken.
89 if(!p_getc(&padding,f))
19723 return qe_invalid;
19724 89 temp_zinit.super_bombs = padding;
19725 89 }
19726
19727 //Back to more OLD item code
19728
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
178 if(s_version < 10)
19729 {
19730
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if((Header->zelda_version > 0x192)||
19731 //new only
19732 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19733 {
19734
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19735 {
19736 return qe_invalid;
19737 }
19738
19739
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wand, temp);
19740
19741
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19742 {
19743 return qe_invalid;
19744 }
19745
19746
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_letter, temp);
19747
19748
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19749 {
19750 return qe_invalid;
19751 }
19752
19753
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_lens, temp);
19754
19755
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19756 {
19757 return qe_invalid;
19758 }
19759
19760
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hookshot, temp);
19761
19762
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19763 {
19764 return qe_invalid;
19765 }
19766
19767
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bait, temp);
19768
19769
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19770 {
19771 return qe_invalid;
19772 }
19773
19774
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hammer, temp);
19775
19776
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19777 {
19778 return qe_invalid;
19779 }
19780
19781
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divinefire, temp);
19782
19783
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19784 {
19785 return qe_invalid;
19786 }
19787
19788
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineescape, temp);
19789
19790
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19791 {
19792 return qe_invalid;
19793 }
19794
19795
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineprotection, temp);
19796
19797
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19798 {
19799 return qe_invalid;
19800 }
19801
19802
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(Header->zelda_version == 0x192)
19803 {
19804 for(int32_t q=0; q<32; q++)
19805 {
19806 if(!p_getc(&padding,f))
19807 {
19808 return qe_invalid;
19809 }
19810 }
19811 }
19812 12 }
19813 12 }
19814
19815 //old only
19816
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
24 if((Header->zelda_version == 0x192)&&(Header->build<174))
19817 {
19818 byte equipment, items; //bit flags
19819
19820 if(!p_getc(&equipment,f))
19821 {
19822 return qe_invalid;
19823 }
19824
19825 temp_zinit.items[iRaft]=(get_bit(&equipment, idE_RAFT)!=0);
19826 temp_zinit.items[iLadder]=(get_bit(&equipment, idE_LADDER)!=0);
19827 temp_zinit.items[iBook]=(get_bit(&equipment, idE_BOOK)!=0);
19828 temp_zinit.items[iMKey]=(get_bit(&equipment, idE_KEY)!=0);
19829 temp_zinit.items[iFlippers]=(get_bit(&equipment, idE_FLIPPERS)!=0);
19830 temp_zinit.items[iBoots]=(get_bit(&equipment, idE_BOOTS)!=0);
19831
19832
19833 if(!p_getc(&items,f))
19834 {
19835 return qe_invalid;
19836 }
19837
19838 temp_zinit.items[iWand]=(get_bit(&items, idI_WAND)!=0);
19839 temp_zinit.items[iLetter]=(get_bit(&items, idI_LETTER)!=0);
19840 temp_zinit.items[iLens]=(get_bit(&items, idI_LENS)!=0);
19841 temp_zinit.items[iHookshot]=(get_bit(&items, idI_HOOKSHOT)!=0);
19842 temp_zinit.items[iBait]=(get_bit(&items, idI_BAIT)!=0);
19843 temp_zinit.items[iHammer]=(get_bit(&items, idI_HAMMER)!=0);
19844 }
19845
19846 if(!p_getc(&temp_zinit.hc,f))
19847 {
19848 return qe_invalid;
19849 }
19850
19851
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 113 times.
125 if(s_version < 14)
19852 {
19853 byte temphp;
19854
19855
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temphp,f))
19856 {
19857 return qe_invalid;
19858 }
19859
19860 12 temp_zinit.start_heart=temphp;
19861
19862
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temphp,f))
19863 {
19864 return qe_invalid;
19865 }
19866
19867 12 temp_zinit.cont_heart=temphp;
19868 12 }
19869 else
19870 {
19871
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.start_heart,f))
19872 {
19873 return qe_invalid;
19874 }
19875
19876
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.cont_heart,f))
19877 {
19878 return qe_invalid;
19879 }
19880 }
19881
19882
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_getc(&temp_zinit.hcp,f))
19883 {
19884 return qe_invalid;
19885 }
19886
19887
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(s_version >= 14)
19888 {
19889
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_getc(&temp_zinit.hcp_per_hc,f))
19890 {
19891 return qe_invalid;
19892 }
19893
19894
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(s_version<16) // July 2007
19895 {
19896 if(get_qr(qr_BRANGPICKUP+1))
19897 temp_zinit.hcp_per_hc = 0xFF;
19898
19899 //Dispose of legacy rule
19900 set_qr(qr_BRANGPICKUP+1, 0);
19901 }
19902 113 }
19903
19904
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 36 times.
125 if(s_version < 29)
19905 {
19906
2/4
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89 times.
✗ Branch 3 not taken.
89 if(!p_getc(&padding,f))
19907 return qe_invalid;
19908 89 temp_zinit.max_bombs = padding;
19909 89 }
19910
19911
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_getc(&temp_zinit.keys,f))
19912 {
19913 return qe_invalid;
19914 }
19915
19916
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetw(&temp_zinit.rupies,f))
19917 {
19918 return qe_invalid;
19919 }
19920
19921
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_getc(&temp_zinit.triforce,f))
19922 {
19923 return qe_invalid;
19924 }
19925
19926
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 113 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
125 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
19927 {
19928
2/2
✓ Branch 0 taken 7232 times.
✓ Branch 1 taken 113 times.
7345 for(int32_t i=0; i<64; i++)
19929 {
19930
2/4
✓ Branch 0 taken 7232 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7232 times.
7232 if(!p_getc(&temp_zinit.map[i],f))
19931 {
19932 return qe_invalid;
19933 }
19934 7232 }
19935
19936
2/2
✓ Branch 0 taken 7232 times.
✓ Branch 1 taken 113 times.
7345 for(int32_t i=0; i<64; i++)
19937 {
19938
2/4
✓ Branch 0 taken 7232 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7232 times.
7232 if(!p_getc(&temp_zinit.compass[i],f))
19939 {
19940 return qe_invalid;
19941 }
19942 7232 }
19943 113 }
19944 else
19945 {
19946
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 12 times.
396 for(int32_t i=0; i<32; i++)
19947 {
19948
2/4
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 384 times.
384 if(!p_getc(&temp_zinit.map[i],f))
19949 {
19950 return qe_invalid;
19951 }
19952 384 }
19953
19954
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 12 times.
396 for(int32_t i=0; i<32; i++)
19955 {
19956
2/4
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 384 times.
384 if(!p_getc(&temp_zinit.compass[i],f))
19957 {
19958 return qe_invalid;
19959 }
19960 384 }
19961 }
19962
19963
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
125 if((Header->zelda_version > 0x192)||
19964 //new only
19965 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19966 {
19967
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 113 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
125 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
19968 {
19969
2/2
✓ Branch 0 taken 7232 times.
✓ Branch 1 taken 113 times.
7345 for(int32_t i=0; i<64; i++)
19970 {
19971
2/4
✓ Branch 0 taken 7232 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7232 times.
7232 if(!p_getc(&temp_zinit.boss_key[i],f))
19972 {
19973 return qe_invalid;
19974 }
19975 7232 }
19976 113 }
19977 else
19978 {
19979
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 12 times.
396 for(int32_t i=0; i<32; i++)
19980 {
19981
2/4
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 384 times.
✗ Branch 3 not taken.
384 if(!p_getc(&temp_zinit.boss_key[i],f))
19982 {
19983 return qe_invalid;
19984 }
19985 384 }
19986 }
19987 125 }
19988
19989
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 2000 times.
2125 for(int32_t i=0; i<16; i++)
19990 {
19991
2/4
✓ Branch 0 taken 2000 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2000 times.
2000 if(!p_getc(&temp_zinit.misc[i],f))
19992 {
19993 return qe_invalid;
19994 }
19995 2000 }
19996
19997
4/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 48 times.
✓ Branch 3 taken 12 times.
173 if(s_version < 15) for(int32_t i=0; i<4; i++)
19998 {
19999
2/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
48 if(!p_getc(&sword_hearts[i],f))
20000 {
20001 return qe_invalid;
20002 }
20003 60 }
20004
20005
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_getc(&temp_zinit.last_map,f))
20006 {
20007 return qe_invalid;
20008 }
20009
20010
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_getc(&temp_zinit.last_screen,f))
20011 {
20012 return qe_invalid;
20013 }
20014
20015
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 113 times.
125 if(s_version < 14)
20016 {
20017 byte tempmp;
20018
20019
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempmp,f))
20020 {
20021 return qe_invalid;
20022 }
20023
20024 12 temp_zinit.max_magic=tempmp;
20025
20026
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempmp,f))
20027 {
20028 return qe_invalid;
20029 }
20030
20031 12 temp_zinit.magic=tempmp;
20032 12 }
20033 else
20034 {
20035
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.max_magic,f))
20036 {
20037 return qe_invalid;
20038 }
20039
20040
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.magic,f))
20041 {
20042 return qe_invalid;
20043 }
20044 }
20045
20046
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(s_version < 15)
20047 {
20048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(s_version < 12)
20049 {
20050 12 temp_zinit.max_magic*=32;
20051 12 temp_zinit.magic*=32;
20052 12 }
20053
20054
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 48 times.
60 for(int32_t i=0; i<4; i++)
20055 {
20056
2/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
48 if(!p_getc(&beam_hearts[i],f))
20057 {
20058 return qe_invalid;
20059 }
20060 48 }
20061
20062
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&beam_percent,f))
20063 {
20064 return qe_invalid;
20065 }
20066 12 }
20067 else
20068 {
20069
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_getc(&temp_zinit.bomb_ratio,f))
20070 {
20071 return qe_invalid;
20072 }
20073 }
20074
20075
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(s_version < 15)
20076 {
20077 byte tempbp;
20078
20079
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 48 times.
60 for(int32_t i=0; i<4; i++)
20080 {
20081
3/8
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
48 if(!(s_version < 14 ? p_getc(&tempbp,f) : p_igetw(&tempbp,f)))
20082 {
20083 return qe_invalid;
20084 }
20085
20086 48 beam_power[i]=tempbp;
20087 48 }
20088
20089
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&hookshot_links,f))
20090 {
20091 return qe_invalid;
20092 }
20093
20094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(s_version>6)
20095 {
20096 if(!p_getc(&hookshot_length,f))
20097 {
20098 return qe_invalid;
20099 }
20100
20101 if(!p_getc(&longshot_links,f))
20102 {
20103 return qe_invalid;
20104 }
20105
20106 if(!p_getc(&longshot_length,f))
20107 {
20108 return qe_invalid;
20109 }
20110 }
20111 12 }
20112
20113
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_getc(&temp_zinit.msg_more_x,f))
20114 {
20115 return qe_invalid;
20116 }
20117
20118
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_getc(&temp_zinit.msg_more_y,f))
20119 {
20120 return qe_invalid;
20121 }
20122
20123
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_getc(&temp_zinit.subscreen,f))
20124 {
20125 return qe_invalid;
20126 }
20127
20128 //old only
20129
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
125 if((Header->zelda_version == 0x192)&&(Header->build<174))
20130 {
20131 for(int32_t i=0; i<32; i++)
20132 {
20133 if(!p_getc(&temp_zinit.boss_key[i],f))
20134 {
20135 return qe_invalid;
20136 }
20137 }
20138 }
20139
20140
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
125 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>173))) //new only
20141 {
20142
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 113 times.
125 if(s_version <= 10)
20143 {
20144 byte tempbyte;
20145
20146
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempbyte,f))
20147 {
20148 return qe_invalid;
20149 }
20150
20151 12 temp_zinit.start_dmap = (word)tempbyte;
20152 12 }
20153 else
20154 {
20155
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.start_dmap,f))
20156 {
20157 return qe_invalid;
20158 }
20159 }
20160
20161
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
20162 {
20163 return qe_invalid;
20164 }
20165 125 }
20166
20167
4/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 36 times.
125 if(s_version>1 && s_version < 29)
20168 {
20169
2/4
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
77 if(!p_getc(&padding,f))
20170 return qe_invalid;
20171 77 temp_zinit.arrows = padding;
20172
20173
2/4
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
77 if(!p_getc(&padding,f))
20174 return qe_invalid;
20175 77 temp_zinit.max_arrows = padding;
20176 77 }
20177
20178
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 113 times.
125 if(s_version>2)
20179 {
20180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(s_version <= 10)
20181 {
20182 for(int32_t i=0; i<OLDMAXLEVELS; i++)
20183 {
20184 if(!p_getc(&(temp_zinit.level_keys[i]),f))
20185 {
20186 return qe_invalid;
20187 }
20188 }
20189 }
20190 else
20191 {
20192
2/2
✓ Branch 0 taken 57856 times.
✓ Branch 1 taken 113 times.
57969 for(int32_t i=0; i<MAXLEVELS; i++)
20193 {
20194
2/4
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57856 times.
✗ Branch 3 not taken.
57856 if(!p_getc(&(temp_zinit.level_keys[i]),f))
20195 {
20196 return qe_invalid;
20197 }
20198 57856 }
20199 }
20200 113 }
20201
20202
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(s_version>3)
20203 {
20204
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.ss_grid_x,f))
20205 {
20206 return qe_invalid;
20207 }
20208
20209
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.ss_grid_y,f))
20210 {
20211 return qe_invalid;
20212 }
20213
20214
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.ss_grid_xofs,f))
20215 {
20216 return qe_invalid;
20217 }
20218
20219
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.ss_grid_yofs,f))
20220 {
20221 return qe_invalid;
20222 }
20223
20224
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.ss_grid_color,f))
20225 {
20226 return qe_invalid;
20227 }
20228
20229
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.ss_bbox_1_color,f))
20230 {
20231 return qe_invalid;
20232 }
20233
20234
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.ss_bbox_2_color,f))
20235 {
20236 return qe_invalid;
20237 }
20238
20239
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.ss_flags,f))
20240 {
20241 return qe_invalid;
20242 }
20243
20244
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 temp_zinit.ss_grid_x=zc_max(temp_zinit.ss_grid_x,1);
20245
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 temp_zinit.ss_grid_y=zc_max(temp_zinit.ss_grid_y,1);
20246 113 }
20247
20248
3/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
125 if(s_version>4 && s_version<15)
20249 {
20250 if(!p_getc(&moving_fairy_hearts,f))
20251 {
20252 return qe_invalid;
20253 }
20254
20255 if(!p_getc(&moving_fairy_heart_percent,f))
20256 {
20257 return qe_invalid;
20258 }
20259 }
20260
20261
3/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
125 if(s_version>5 && s_version < 10)
20262 {
20263 if(!p_getc(&temp,f))
20264 {
20265 return qe_invalid;
20266 }
20267
20268 addOldStyleFamily(&temp_zinit, itemsbuf, itype_quiver, temp);
20269 }
20270
20271
3/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
125 if(s_version>6 && s_version<15)
20272 {
20273 if(!p_getc(&stationary_fairy_hearts,f))
20274 {
20275 return qe_invalid;
20276 }
20277
20278 if(!p_getc(&stationary_fairy_heart_percent,f))
20279 {
20280 return qe_invalid;
20281 }
20282
20283 if(!p_getc(&moving_fairy_magic,f))
20284 {
20285 return qe_invalid;
20286 }
20287
20288 if(!p_getc(&moving_fairy_magic_percent,f))
20289 {
20290 return qe_invalid;
20291 }
20292
20293 if(!p_getc(&stationary_fairy_magic,f))
20294 {
20295 return qe_invalid;
20296 }
20297
20298 if(!p_getc(&stationary_fairy_magic_percent,f))
20299 {
20300 return qe_invalid;
20301 }
20302
20303 if(!p_getc(&blue_potion_hearts,f))
20304 {
20305 return qe_invalid;
20306 }
20307
20308 if(!p_getc(&blue_potion_heart_percent,f))
20309 {
20310 return qe_invalid;
20311 }
20312
20313 if(!p_getc(&red_potion_hearts,f))
20314 {
20315 return qe_invalid;
20316 }
20317
20318 if(!p_getc(&red_potion_heart_percent,f))
20319 {
20320 return qe_invalid;
20321 }
20322
20323 if(!p_getc(&blue_potion_magic,f))
20324 {
20325 return qe_invalid;
20326 }
20327
20328 if(!p_getc(&blue_potion_magic_percent,f))
20329 {
20330 return qe_invalid;
20331 }
20332
20333 if(!p_getc(&red_potion_magic,f))
20334 {
20335 return qe_invalid;
20336 }
20337
20338 if(!p_getc(&red_potion_magic_percent,f))
20339 {
20340 return qe_invalid;
20341 }
20342 }
20343
20344
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(s_version>6)
20345 {
20346
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_getc(&temp_zinit.subscreen_style,f))
20347 {
20348 return qe_invalid;
20349 }
20350 113 }
20351
20352
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(s_version>7)
20353 {
20354
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_getc(&temp_zinit.usecustomsfx,f))
20355 {
20356 return qe_invalid;
20357 }
20358 113 }
20359
20360
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(s_version>8)
20361 {
20362
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.max_rupees,f))
20363 {
20364 return qe_invalid;
20365 }
20366
20367
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.max_keys,f))
20368 {
20369 return qe_invalid;
20370 }
20371 113 }
20372
20373
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(s_version>16)
20374 {
20375
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_getc(&temp_zinit.gravity,f))
20376 {
20377 return qe_invalid;
20378 }
20379
20380
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.terminalv,f))
20381 {
20382 return qe_invalid;
20383 }
20384
20385
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_getc(&temp_zinit.msg_speed,f))
20386 {
20387 return qe_invalid;
20388 }
20389
20390
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_getc(&temp_zinit.transition_type,f))
20391 {
20392 return qe_invalid;
20393 }
20394
20395
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
20396 {
20397 return qe_invalid;
20398 }
20399 113 }
20400
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 else if (replay_version_check(0, 13))
20401 12 temp_zinit.msg_speed = 0;
20402
20403
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(s_version>17)
20404 {
20405
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
20406 {
20407 return qe_invalid;
20408 }
20409 113 }
20410
20411 //expaned init data for larger values in 2.55
20412
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if ( s_version >= 19 ) //expand init data bombs, sbombs, and arrows to 0xFFFF
20413 {
20414
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.bombs,f))
20415 {
20416 return qe_invalid;
20417 }
20418
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.super_bombs,f))
20419 {
20420 return qe_invalid;
20421 }
20422
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.max_bombs,f))
20423 {
20424 return qe_invalid;
20425 }
20426
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.max_sbombs,f))
20427 {
20428 return qe_invalid;
20429 }
20430
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.arrows,f))
20431 {
20432 return qe_invalid;
20433 }
20434
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.max_arrows,f))
20435 {
20436 return qe_invalid;
20437 }
20438
20439 36 }
20440
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if ( s_version >= 20 )
20441 {
20442
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.heroStep,f))
20443 {
20444 return qe_invalid;
20445 }
20446 36 }
20447 else
20448 {
20449 89 temp_zinit.heroStep = 150; //1.5 pixels per frame
20450 }
20451
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if ( s_version >= 21 )
20452 {
20453
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.subscrSpeed,f))
20454 {
20455 return qe_invalid;
20456 }
20457 36 }
20458 else
20459 {
20460 89 temp_zinit.subscrSpeed = 1; //3 pixels per frame
20461 }
20462 //old only
20463
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
125 if((Header->zelda_version == 0x192)&&(Header->build<174))
20464 {
20465 byte items2;
20466
20467 if(!p_getc(&items2,f))
20468 {
20469 return qe_invalid;
20470 }
20471
20472 temp_zinit.items[iDivineFire]=(get_bit(&items2, idI_DFIRE)!=0);
20473 temp_zinit.items[iDivineEscape]=(get_bit(&items2, idI_FWIND)!=0);
20474 temp_zinit.items[iDivineProtection]=(get_bit(&items2, idI_NLOVE)!=0);
20475 }
20476
20477
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(Header->zelda_version < 0x193)
20478 {
20479 for(int32_t q=0; q<96; q++)
20480 {
20481 if(!p_getc(&padding,f))
20482 {
20483 return qe_invalid;
20484 }
20485 }
20486
20487 //new only
20488 if((Header->zelda_version == 0x192)&&(Header->build>173))
20489 {
20490 if(!p_getc(&padding,f))
20491 {
20492 return qe_invalid;
20493 }
20494
20495 if(!p_getc(&padding,f))
20496 {
20497 return qe_invalid;
20498 }
20499 }
20500 }
20501 125 }
20502
20503
3/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
182 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<15)))
20504 {
20505 //temp_zinit.shield=i_smallshield;
20506
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 53 times.
69 int32_t sshieldid = getItemID(itemsbuf, itype_shield, i_smallshield);
20507
20508
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(sshieldid != -1)
20509 16 temp_zinit.items[sshieldid] = true;
20510 16 }
20511
20512
3/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<27)))
20513 {
20514 4 temp_zinit.hc=3;
20515 4 temp_zinit.start_heart=3;
20516 4 temp_zinit.cont_heart=3;
20517 4 temp_zinit.max_bombs=8;
20518 4 }
20519
20520
3/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<50)))
20521 {
20522 4 sword_hearts[0]=0;
20523 4 sword_hearts[1]=5;
20524 4 sword_hearts[2]=12;
20525 4 sword_hearts[3]=21;
20526 4 }
20527
20528
3/4
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
129 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<51)))
20529 {
20530 4 temp_zinit.last_map=0;
20531 4 temp_zinit.last_screen=0;
20532 4 }
20533
20534
3/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<68)))
20535 {
20536 4 temp_zinit.max_magic=0;
20537 4 temp_zinit.magic=0;
20538
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
20539 4 }
20540
20541
3/4
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
129 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<129)))
20542 {
20543
20544
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t x=0; x<4; x++)
20545 {
20546 16 beam_hearts[x]=100;
20547 16 }
20548
20549
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t i=0; i<idBP_MAX; i++)
20550 {
20551
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
16 set_bit(&beam_percent,i,!get_qr(qr_LENSHINTS+i));
20552
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 set_qr(qr_LENSHINTS+i,0);
20553 16 }
20554
20555
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 16 times.
20 for(int32_t x=0; x<4; x++)
20556 {
20557
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 beam_power[x]=get_qr(qr_HIDECARRIEDITEMS)?50:100;
20558 16 }
20559
20560
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_qr(qr_HIDECARRIEDITEMS,0);
20561 4 hookshot_links=100;
20562 4 temp_zinit.msg_more_x=224;
20563 4 temp_zinit.msg_more_y=64;
20564 4 }
20565
20566 // Okay, let's put these legacy values into itemsbuf.
20567
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version < 15)
20568
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4096 times.
4112 for(int32_t i=0; i<MAXITEMS; i++)
20569 {
20570
11/11
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 16 times.
✓ Branch 7 taken 16 times.
✓ Branch 8 taken 3936 times.
✓ Branch 9 taken 16 times.
✓ Branch 10 taken 16 times.
4096 switch(i)
20571 {
20572 case iFairyStill:
20573 16 itemsbuf[i].misc1 = stationary_fairy_hearts;
20574 16 itemsbuf[i].misc2 = stationary_fairy_magic;
20575 16 itemsbuf[i].misc3 = 0;
20576 16 itemsbuf[i].flags |= stationary_fairy_heart_percent ? ITEM_FLAG1 : 0;
20577 16 itemsbuf[i].flags |= stationary_fairy_magic_percent ? ITEM_FLAG2 : 0;
20578 16 break;
20579
20580 case iFairyMoving:
20581 16 itemsbuf[i].misc1 = moving_fairy_hearts;
20582 16 itemsbuf[i].misc2 = moving_fairy_magic;
20583 16 itemsbuf[i].misc3 = 50;
20584 16 itemsbuf[i].flags |= moving_fairy_heart_percent ? ITEM_FLAG1 : 0;
20585 16 itemsbuf[i].flags |= moving_fairy_magic_percent ? ITEM_FLAG2 : 0;
20586 16 break;
20587
20588 case iRPotion:
20589 16 itemsbuf[i].misc1 = red_potion_hearts;
20590 16 itemsbuf[i].misc2 = red_potion_magic;
20591 16 itemsbuf[i].flags |= red_potion_heart_percent ? ITEM_FLAG1 : 0;
20592 16 itemsbuf[i].flags |= red_potion_magic_percent ? ITEM_FLAG2 : 0;
20593 16 break;
20594
20595 case iBPotion:
20596 16 itemsbuf[i].misc1 = blue_potion_hearts;
20597 16 itemsbuf[i].misc2 = blue_potion_magic;
20598 16 itemsbuf[i].flags |= blue_potion_heart_percent ? ITEM_FLAG1 : 0;
20599 16 itemsbuf[i].flags |= blue_potion_magic_percent ? ITEM_FLAG2 : 0;
20600 16 break;
20601
20602 case iSword:
20603 16 itemsbuf[i].pickup_hearts = sword_hearts[0];
20604 16 itemsbuf[i].misc1 = beam_hearts[0];
20605 16 itemsbuf[i].misc2 = beam_power[0];
20606 // It seems that ITEM_FLAG1 was already added by reset_itembuf()...
20607
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 itemsbuf[i].flags &= (!get_bit(&beam_percent,0)) ? ~ITEM_FLAG1 : ~0;
20608 16 break;
20609
20610 case iWSword:
20611 16 itemsbuf[i].pickup_hearts = sword_hearts[1];
20612 16 itemsbuf[i].misc1 = beam_hearts[1];
20613 16 itemsbuf[i].misc2 = beam_power[1];
20614
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 itemsbuf[i].flags &= (!get_bit(&beam_percent,1)) ? ~ITEM_FLAG1 : ~0;
20615 16 break;
20616
20617 case iMSword:
20618 16 itemsbuf[i].pickup_hearts = sword_hearts[2];
20619 16 itemsbuf[i].misc1 = beam_hearts[2];
20620 16 itemsbuf[i].misc2 = beam_power[2];
20621
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 itemsbuf[i].flags &= (!get_bit(&beam_percent,2)) ? ~ITEM_FLAG1 : ~0;
20622 16 break;
20623
20624 case iXSword:
20625 16 itemsbuf[i].pickup_hearts = sword_hearts[3];
20626 16 itemsbuf[i].misc1 = beam_hearts[3];
20627 16 itemsbuf[i].misc2 = beam_power[3];
20628
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 itemsbuf[i].flags &= (!get_bit(&beam_percent,3)) ? ~ITEM_FLAG1 : ~0;
20629 16 break;
20630
20631 case iHookshot:
20632 16 itemsbuf[i].misc1 = hookshot_length;
20633 16 itemsbuf[i].misc2 = hookshot_links;
20634 16 break;
20635
20636 case iLongshot:
20637 16 itemsbuf[i].misc1 = longshot_length;
20638 16 itemsbuf[i].misc2 = longshot_links;
20639 16 break;
20640 }
20641 4112 }
20642
20643
3/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<168)))
20644 {
20645 //was new subscreen rule
20646
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 temp_zinit.subscreen=get_qr(qr_FREEFORM)?1:0;
20647
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_qr(qr_FREEFORM,0);
20648 4 }
20649
20650
3/4
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
129 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<185)))
20651 {
20652 4 temp_zinit.start_dmap=0;
20653 4 }
20654
20655
3/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<186)))
20656 {
20657
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 temp_zinit.heroAnimationStyle=get_qr(qr_BSZELDA)?1:0;
20658 4 }
20659
20660
4/6
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 113 times.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
129 if(s_version < 16 && get_bit(deprecated_rules, qr_COOLSCROLL+1))
20661 {
20662 //addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, 4); //is this needed?
20663 temp_zinit.max_rupees=999;
20664 //temp_zinit.rupies=999; //This rule only gave you an invisible max wallet; it did not give you max rupies.
20665 }
20666
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(Header->zelda_version < 0x190) //1.84 bugfix. -Z
20667 {
20668 //temp_zinit.items[iBombBag] = true; //No, this is 30 max bombs!
20669 temp_zinit.max_bombs = 8;
20670 }
20671 // al_trace("About to copy over new init data values for quest made in: %x\n", Header->zelda_version);
20672 //time to ensure that we port all new values properly:
20673
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(Header->zelda_version < 0x250)
20674 {
20675
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 temp_zinit.max_sbombs = temp_zinit.bomb_ratio > 0 ? ( temp_zinit.max_bombs/temp_zinit.bomb_ratio ) : (temp_zinit.max_bombs/4);
20676 16 }
20677
20678
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(s_version > 21)
20679 {
20680
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.hp_per_heart,f))
20681 {
20682 return qe_invalid;
20683 }
20684
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.magic_per_block,f))
20685 {
20686 return qe_invalid;
20687 }
20688
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
20689 {
20690 return qe_invalid;
20691 }
20692
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
20693 {
20694 return qe_invalid;
20695 }
20696 36 }
20697 else
20698 {
20699 93 temp_zinit.hp_per_heart = 16; //HP_PER_HEART, previously hardcoded
20700 93 temp_zinit.magic_per_block = 32; //MAGICPERBLOCK, previously hardcoded
20701 93 temp_zinit.hero_damage_multiplier = 2; //DAMAGE_MULTIPLIER, previously hardcoded
20702 93 temp_zinit.ene_damage_multiplier = 4; //(HP_PER_HEART/4), previously hardcoded
20703 }
20704
20705
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(s_version > 22)
20706 {
20707
2/2
✓ Branch 0 taken 900 times.
✓ Branch 1 taken 36 times.
936 for(int32_t q = 0; q < 25; ++q)
20708 {
20709
2/4
✓ Branch 0 taken 900 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 900 times.
900 if(!p_igetw(&temp_zinit.scrcnt[q],f))
20710 {
20711 return qe_invalid;
20712 }
20713 900 }
20714
2/2
✓ Branch 0 taken 900 times.
✓ Branch 1 taken 36 times.
936 for(int32_t q = 0; q < 25; ++q)
20715 {
20716
2/4
✓ Branch 0 taken 900 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 900 times.
900 if(!p_igetw(&temp_zinit.scrmaxcnt[q],f))
20717 {
20718 return qe_invalid;
20719 }
20720 900 }
20721 36 }
20722 else
20723 {
20724
2/2
✓ Branch 0 taken 2325 times.
✓ Branch 1 taken 93 times.
2418 for(int32_t q = 0; q < 25; ++q)
20725 {
20726 2325 temp_zinit.scrcnt[q] = 0;
20727 2325 temp_zinit.scrmaxcnt[q] = 0;
20728 2325 }
20729 }
20730
20731
20732
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(s_version > 23)
20733 {
20734
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.dither_type,f))
20735 {
20736 return qe_invalid;
20737 }
20738
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.dither_arg,f))
20739 {
20740 return qe_invalid;
20741 }
20742
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.dither_percent,f))
20743 {
20744 return qe_invalid;
20745 }
20746
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.def_lightrad,f))
20747 {
20748 return qe_invalid;
20749 }
20750
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.transdark_percent,f))
20751 {
20752 return qe_invalid;
20753 }
20754 36 }
20755 else
20756 {
20757 93 temp_zinit.dither_type = 0;
20758 93 temp_zinit.dither_arg = 0;
20759 93 temp_zinit.dither_percent = 20;
20760 93 temp_zinit.def_lightrad = 24;
20761 93 temp_zinit.transdark_percent = 0;
20762 }
20763
20764
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(s_version > 24)
20765 {
20766
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.darkcol,f))
20767 {
20768 return qe_invalid;
20769 }
20770 36 }
20771 else
20772 {
20773 93 temp_zinit.darkcol = BLACK;
20774 }
20775
20776
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(s_version > 25)
20777 {
20778
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetl(&temp_zinit.gravity2,f))
20779 {
20780 return qe_invalid;
20781 }
20782
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetl(&temp_zinit.swimgravity,f))
20783 {
20784 return qe_invalid;
20785 }
20786 36 }
20787 else
20788 {
20789 93 temp_zinit.gravity2 = temp_zinit.gravity*100;
20790 93 temp_zinit.swimgravity = 5;
20791 }
20792
20793
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(s_version > 26)
20794 {
20795
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
20796 {
20797 return qe_invalid;
20798 }
20799
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
20800 {
20801 return qe_invalid;
20802 }
20803
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
20804 {
20805 return qe_invalid;
20806 }
20807 36 }
20808 else
20809 {
20810 93 temp_zinit.heroSideswimUpStep = 150;
20811 93 temp_zinit.heroSideswimSideStep = 100;
20812 93 temp_zinit.heroSideswimDownStep = 75;
20813 }
20814
20815
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(s_version > 27)
20816 {
20817
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetl(&temp_zinit.exitWaterJump,f))
20818 {
20819 return qe_invalid;
20820 }
20821 36 }
20822 else
20823 {
20824 93 temp_zinit.exitWaterJump = 0;
20825 }
20826
20827
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(s_version > 29)
20828 {
20829
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetl(&temp_zinit.bunny_ltm,f))
20830 {
20831 return qe_invalid;
20832 }
20833 36 }
20834 else
20835 {
20836 93 temp_zinit.bunny_ltm = 0;
20837 }
20838
20839
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(s_version > 30)
20840 {
20841
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.switchhookstyle,f))
20842 {
20843 return qe_invalid;
20844 }
20845 36 }
20846 else
20847 {
20848 93 temp_zinit.switchhookstyle = 1;
20849 }
20850
20851
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(s_version > 31)
20852 {
20853
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.magicdrainrate,f))
20854 {
20855 return qe_invalid;
20856 }
20857 36 }
20858 else
20859 {
20860
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 temp_zinit.magicdrainrate = (get_bit(temp_zinit.misc,idM_DOUBLEMAGIC) ? 1 : 2);
20861
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
20862 }
20863
20864
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 temp_zinit.clear_genscript();
20865
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 95 times.
129 if(s_version > 32)
20866 {
20867 34 word numgenscript = 0;
20868
2/4
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
34 if(!p_igetw(&numgenscript,f))
20869 return qe_invalid;
20870
2/4
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34 times.
34 if (!(numgenscript >= 0 && numgenscript <= NUMSCRIPTSGENERIC))
20871 return qe_invalid;
20872
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 for(auto q = 1; q < numgenscript; ++q)
20873 {
20874 if(!p_getc(&padding,f))
20875 return qe_invalid;
20876 if(!(padding&2))
20877 continue;
20878 temp_zinit.gen_doscript[q] = padding&1;
20879 if(!p_igetw(&temp_zinit.gen_exitState[q],f))
20880 return qe_invalid;
20881 if(!p_igetw(&temp_zinit.gen_reloadState[q],f))
20882 return qe_invalid;
20883 for(auto p = 0; p < 8; ++p)
20884 if(!p_igetl(&temp_zinit.gen_initd[q][p],f))
20885 return qe_invalid;
20886 if(!p_igetl(&temp_zinit.gen_dataSize[q],f))
20887 return qe_invalid;
20888 if(!p_getlvec<int32_t>(&temp_zinit.gen_data[q],f))
20889 return qe_invalid;
20890 if(!p_igetl(&temp_zinit.gen_eventstate[q],f))
20891 return qe_invalid;
20892 }
20893 34 }
20894
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 98 times.
129 if(s_version > 33)
20895 {
20896
2/4
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
31 if(!p_getc(&temp_zinit.hero_swim_mult,f))
20897 return qe_invalid;
20898
2/4
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
31 if(!p_getc(&temp_zinit.hero_swim_div,f))
20899 return qe_invalid;
20900 31 }
20901
20902
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 zinit = temp_zinit;
20903
20904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(zinit.heroAnimationStyle==las_zelda3slow)
20905 {
20906 hero_animation_speed=2;
20907 }
20908 else
20909 {
20910 129 hero_animation_speed=1;
20911 }
20912
20913 129 return 0;
20914 485 }
20915
20916 /*
20917 void setupitemdropsets()
20918 {
20919 for(int32_t i=0; i<isMAX; i++)
20920 {
20921 memcpy(&item_drop_sets[i], &default_item_drop_sets[i], sizeof(item_drop_object));
20922 }
20923 }
20924 */
20925
20926 117 int32_t readitemdropsets(PACKFILE *f, int32_t version, word build)
20927 {
20928 117 build=build; // here to prevent compiler warnings
20929 dword dummy_dword;
20930 117 word item_drop_sets_to_read=0;
20931 item_drop_object tempitemdrop;
20932 117 word s_version=0, s_cversion=0;
20933
20934
2/2
✓ Branch 0 taken 29952 times.
✓ Branch 1 taken 117 times.
30069 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
20935 {
20936 29952 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
20937 29952 }
20938
20939
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 4 times.
117 if(version > 0x192)
20940 {
20941 113 item_drop_sets_to_read=0;
20942
20943 //section version info
20944
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&s_version,f))
20945 {
20946 return qe_invalid;
20947 }
20948
20949 113 FFCore.quest_format[vItemDropsets] = s_version;
20950
20951 //al_trace("Item drop sets version %d\n", s_version);
20952
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&s_cversion,f))
20953 {
20954 return qe_invalid;
20955 }
20956
20957 //section size
20958
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetl(&dummy_dword,f))
20959 {
20960 return qe_invalid;
20961 }
20962
20963 //finally... section data
20964
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&item_drop_sets_to_read,f))
20965 {
20966 return qe_invalid;
20967 }
20968
20969
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if (!(item_drop_sets_to_read >= 0 && item_drop_sets_to_read <= MAXITEMDROPSETS))
20970 {
20971 return qe_invalid;
20972 }
20973 113 }
20974 else
20975 {
20976 4 init_item_drop_sets();
20977 }
20978
20979
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 113 times.
117 if(s_version>=1)
20980 {
20981
2/2
✓ Branch 0 taken 2069 times.
✓ Branch 1 taken 113 times.
2182 for(int32_t i=0; i<item_drop_sets_to_read; i++)
20982 {
20983
1/2
✓ Branch 0 taken 2069 times.
✗ Branch 1 not taken.
2069 if(!pfread(tempitemdrop.name,sizeof(tempitemdrop.name),f))
20984 {
20985 return qe_invalid;
20986 }
20987
20988
2/2
✓ Branch 0 taken 20690 times.
✓ Branch 1 taken 2069 times.
22759 for(int32_t j=0; j<10; ++j)
20989 {
20990
1/2
✓ Branch 0 taken 20690 times.
✗ Branch 1 not taken.
20690 if(!p_igetw(&tempitemdrop.item[j],f))
20991 {
20992 return qe_invalid;
20993 }
20994 20690 }
20995
20996
2/2
✓ Branch 0 taken 22759 times.
✓ Branch 1 taken 2069 times.
24828 for(int32_t j=0; j<11; ++j)
20997 {
20998
1/2
✓ Branch 0 taken 22759 times.
✗ Branch 1 not taken.
22759 if(!p_igetw(&tempitemdrop.chance[j],f))
20999 {
21000 return qe_invalid;
21001 }
21002 22759 }
21003
21004 // Dec 2008: Addition of the 'Tall Grass' set, #12,
21005 // overrides the quest's set #12.
21006
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2069 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2069 if(s_version<2 && i==12)
21007 continue;
21008
21009 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
21010
1/4
✓ Branch 0 taken 2069 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2069 if(s_version<2) for(int32_t j=0; j<10; ++j)
21011 {
21012 int32_t it = tempitemdrop.item[j];
21013
21014 if((itemsbuf[it].family == itype_rupee
21015 && ((itemsbuf[it].amount)&0xFFF) == 10)
21016 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
21017 {
21018 tempitemdrop.chance[j+1]=0;
21019 }
21020 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
21021 {
21022 tempitemdrop.chance[j+1]=0;
21023 }
21024
21025 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
21026 if(itemsbuf[it].family == itype_misc)
21027 {
21028 // If a non-gameplay item was selected, then item drop was aborted.
21029 // Reflect this by increasing the 'Nothing' chance accordingly.
21030 tempitemdrop.chance[0]+=tempitemdrop.chance[j+1];
21031 tempitemdrop.chance[j+1]=0;
21032 }
21033 }
21034
21035 2069 memcpy(&item_drop_sets[i], &tempitemdrop, sizeof(item_drop_object));
21036 2069 }
21037 113 }
21038
21039 117 return 0;
21040 117 }
21041
21042 113 int32_t readfavorites(PACKFILE *f, int32_t, word)
21043 {
21044 int32_t temp_num;
21045 dword dummy_dword;
21046 word num_favorite_combos;
21047 word num_favorite_combo_aliases;
21048 113 word s_version=0, s_cversion=0;
21049
21050 //section version info
21051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(!p_igetw(&s_version,f))
21052 {
21053 return qe_invalid;
21054 }
21055
21056 113 FFCore.quest_format[vFavourites] = s_version;
21057
21058
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&s_cversion,f))
21059 {
21060 return qe_invalid;
21061 }
21062
21063 //section size
21064
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetl(&dummy_dword,f))
21065 {
21066 return qe_invalid;
21067 }
21068
21069 113 word per_row = FAVORITECOMBO_PER_ROW;
21070
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 31 times.
113 if(s_version >= 3)
21071
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_igetw(&per_row,f))
21072 return qe_invalid;
21073 //finally... section data
21074
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&num_favorite_combos,f))
21075 {
21076 return qe_invalid;
21077 }
21078
21079 //Hack; port old favorite combos
21080
3/4
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 82 times.
113 if(s_version < 3 && num_favorite_combos == 100)
21081 82 per_row = 13;
21082
21083
2/2
✓ Branch 0 taken 33900 times.
✓ Branch 1 taken 113 times.
34013 for(int q = 0; q < MAXFAVORITECOMBOS; ++q)
21084 33900 favorite_combos[q] = -1;
21085
2/2
✓ Branch 0 taken 33900 times.
✓ Branch 1 taken 113 times.
34013 for(int q = 0; q < MAXFAVORITECOMBOALIASES; ++q)
21086 33900 favorite_comboaliases[q] = -1;
21087
2/2
✓ Branch 0 taken 8735 times.
✓ Branch 1 taken 113 times.
8848 for(int32_t i=0; i<num_favorite_combos; i++)
21088 {
21089
1/2
✓ Branch 0 taken 8735 times.
✗ Branch 1 not taken.
8735 if(!p_igetl(&temp_num,f))
21090 {
21091 return qe_invalid;
21092 }
21093
21094
2/2
✓ Branch 0 taken 535 times.
✓ Branch 1 taken 8200 times.
8735 if(per_row == FAVORITECOMBO_PER_ROW)
21095 535 favorite_combos[i]=temp_num;
21096 else
21097 {
21098 8200 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
21099 8200 favorite_combos[new_i]=temp_num;
21100 }
21101 8735 }
21102
21103
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&num_favorite_combo_aliases,f))
21104 {
21105 return qe_invalid;
21106 }
21107
21108
2/2
✓ Branch 0 taken 8200 times.
✓ Branch 1 taken 113 times.
8313 for(int32_t i=0; i<num_favorite_combo_aliases; i++)
21109 {
21110
1/2
✓ Branch 0 taken 8200 times.
✗ Branch 1 not taken.
8200 if(!p_igetl(&temp_num,f))
21111 {
21112 return qe_invalid;
21113 }
21114
21115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8200 times.
8200 if(per_row == FAVORITECOMBO_PER_ROW)
21116 favorite_comboaliases[i]=temp_num;
21117 else
21118 {
21119 8200 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
21120 8200 favorite_comboaliases[new_i]=temp_num;
21121 }
21122 8200 }
21123
21124 113 word max_combo_cols = 0;
21125 113 word max_mappages = 0;
21126
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 31 times.
113 if(s_version >= 2)
21127 {
21128
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_igetw(&max_combo_cols,f))
21129 return qe_invalid;
21130 31 int32_t tmp = 0, tmp2 = 0, tmp3 = 0;
21131
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 31 times.
155 for(int q = 0; q < max_combo_cols; ++q)
21132 {
21133
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetl(&tmp,f))
21134 return qe_invalid;
21135
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetl(&tmp2,f))
21136 return qe_invalid;
21137
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetl(&tmp3,f))
21138 return qe_invalid;
21139
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(q < MAX_COMBO_COLS)
21140 {
21141 124 First[q] = tmp;
21142 124 combo_alistpos[q] = tmp2;
21143 124 combo_pool_listpos[q] = tmp3;
21144 124 }
21145 124 }
21146
21147
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_igetw(&max_mappages,f))
21148 return qe_invalid;
21149
2/2
✓ Branch 0 taken 279 times.
✓ Branch 1 taken 31 times.
310 for(int q = 0; q < max_mappages; ++q)
21150 {
21151
1/2
✓ Branch 0 taken 279 times.
✗ Branch 1 not taken.
279 if(!p_igetl(&tmp,f))
21152 return qe_invalid;
21153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 279 times.
279 if(!p_igetl(&tmp2,f))
21154 return qe_invalid;
21155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 279 times.
279 if(q < MAX_MAPPAGE_BTNS)
21156 {
21157 279 map_page[q].map = tmp;
21158 279 map_page[q].screen = tmp2;
21159 279 }
21160 279 }
21161 31 }
21162
21163
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 113 times.
441 for(int q = max_combo_cols; q < MAX_COMBO_COLS; ++q)
21164 {
21165 328 First[q] = 0;
21166 328 combo_alistpos[q] = 0;
21167 328 combo_pool_listpos[q] = 0;
21168 328 }
21169
2/2
✓ Branch 0 taken 738 times.
✓ Branch 1 taken 113 times.
851 for(int q = max_mappages; q < MAX_MAPPAGE_BTNS; ++q)
21170 {
21171 738 map_page[q].map = 0;
21172 738 map_page[q].screen = 0;
21173 738 }
21174
21175 113 return 0;
21176 113 }
21177
21178 /*
21179 switch (ret) {
21180 case 0:
21181 break;
21182
21183 case qe_invalid:
21184 goto invalid;
21185 break;
21186 default:
21187 pack_fclose(f);
21188 if(!oldquest)
21189 delete_file(tmpfilename);
21190 return ret;
21191 break;
21192 }
21193 */
21194
21195 const char *skip_text[skip_max]=
21196 {
21197 "skip_header", "skip_rules", "skip_strings", "skip_misc",
21198 "skip_tiles", "skip_combos", "skip_comboaliases", "skip_csets",
21199 "skip_maps", "skip_dmaps", "skip_doors", "skip_items",
21200 "skip_weapons", "skip_colors", "skip_icons", "skip_initdata",
21201 "skip_guys", "skip_herosprites", "skip_subscreens", "skip_ffscript",
21202 "skip_sfx", "skip_midis", "skip_cheats", "skip_itemdropsets",
21203 "skip_favorites"
21204 };
21205
21206
21207 void port250QuestRules(){
21208
21209 portCandleRules(); //Candle
21210 portBombRules();
21211
21212 }
21213
21214 void portCandleRules()
21215 {
21216 bool hurtshero = get_qr(qr_FIREPROOFHERO);
21217 //itemdata itemsbuf;
21218 for ( int32_t q = 0; q < MAXITEMS; q++ )
21219 {
21220 if ( itemsbuf[q].family == itype_candle )
21221 {
21222 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21223 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21224 }
21225 }
21226 }
21227
21228 void portBombRules()
21229 {
21230 bool hurtshero = get_qr(qr_OUCHBOMBS);
21231 //itemdata itemsbuf;
21232 for ( int32_t q = 0; q < MAXITEMS; q++ )
21233 {
21234 if ( itemsbuf[q].family == itype_bomb )
21235 {
21236 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21237 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21238 }
21239 }
21240 }
21241
21242 2892 static int section_id_to_enum(int id)
21243 {
21244
24/27
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 125 times.
✓ Branch 3 taken 125 times.
✓ Branch 4 taken 125 times.
✓ Branch 5 taken 125 times.
✓ Branch 6 taken 113 times.
✓ Branch 7 taken 125 times.
✓ Branch 8 taken 125 times.
✓ Branch 9 taken 125 times.
✓ Branch 10 taken 125 times.
✓ Branch 11 taken 125 times.
✓ Branch 12 taken 125 times.
✓ Branch 13 taken 113 times.
✓ Branch 14 taken 113 times.
✓ Branch 15 taken 125 times.
✓ Branch 16 taken 125 times.
✓ Branch 17 taken 113 times.
✓ Branch 18 taken 113 times.
✓ Branch 19 taken 113 times.
✓ Branch 20 taken 113 times.
✓ Branch 21 taken 125 times.
✓ Branch 22 taken 125 times.
✓ Branch 23 taken 113 times.
✓ Branch 24 taken 113 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
2892 switch (id)
21245 {
21246 case ID_HEADER: return skip_header;
21247 125 case ID_RULES: return skip_rules;
21248 125 case ID_STRINGS: return skip_strings;
21249 125 case ID_MISC: return skip_misc;
21250 125 case ID_TILES: return skip_tiles;
21251 125 case ID_COMBOS: return skip_combos;
21252 113 case ID_COMBOALIASES: return skip_comboaliases;
21253 125 case ID_CSETS: return skip_csets;
21254 125 case ID_MAPS: return skip_maps;
21255 125 case ID_DMAPS: return skip_dmaps;
21256 125 case ID_DOORS: return skip_doors;
21257 125 case ID_ITEMS: return skip_items;
21258 125 case ID_WEAPONS: return skip_weapons;
21259 113 case ID_COLORS: return skip_colors;
21260 113 case ID_ICONS: return skip_icons;
21261 125 case ID_INITDATA: return skip_initdata;
21262 125 case ID_GUYS: return skip_guys;
21263 113 case ID_HEROSPRITES: return skip_herosprites;
21264 113 case ID_SUBSCREEN: return skip_subscreens;
21265 113 case ID_FFSCRIPT: return skip_ffscript;
21266 113 case ID_SFX: return skip_sfx;
21267 125 case ID_MIDIS: return skip_midis;
21268 125 case ID_CHEATS: return skip_cheats;
21269 113 case ID_ITEMDROPSETS: return skip_itemdropsets;
21270 113 case ID_FAVORITES: return skip_favorites;
21271 case ID_ZINFO: return skip_zinfo;
21272 }
21273
21274 return -1;
21275 2892 }
21276
21277 2892 static int maybe_skip_section(PACKFILE* f, dword& section_id, const byte* skip_flags)
21278 {
21279 2892 int section_enum = section_id_to_enum(section_id);
21280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2892 times.
2892 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
21281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2892 times.
2892 if (skip)
21282 {
21283 word s_version;
21284 if (!p_igetw(&s_version,f))
21285 {
21286 return qe_invalid;
21287 }
21288
21289 word c_version;
21290 if (!p_igetw(&c_version,f))
21291 {
21292 return qe_invalid;
21293 }
21294
21295 if (section_id == ID_RULES && s_version > 16)
21296 {
21297 dword dummy;
21298 if (!p_igetl(&dummy,f))
21299 {
21300 return qe_invalid;
21301 }
21302 }
21303
21304 if (section_id == ID_FFSCRIPT && s_version >= 18)
21305 {
21306 word dummy;
21307 if (!p_igetw(&dummy,f))
21308 {
21309 return qe_invalid;
21310 }
21311 }
21312
21313 dword section_length;
21314 if (!p_igetl(&section_length,f))
21315 {
21316 return qe_invalid;
21317 }
21318
21319 if (pack_fseek(f, section_length))
21320 {
21321 return qe_invalid;
21322 }
21323
21324 if (!pack_feof(f))
21325 {
21326 if (!p_mgetl(&section_id,f))
21327 {
21328 return qe_invalid;
21329 }
21330 }
21331
21332 return qe_cancel;
21333 }
21334
21335 2892 return qe_OK;
21336 2892 }
21337
21338 //Internal function for loadquest wrapper
21339 129 int32_t _lq_int(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, const byte *skip_flags, byte printmetadata)
21340 {
21341 129 DMapEditorLastMaptileUsed = 0;
21342 129 combosread=false;
21343 129 mapsread=false;
21344 129 fixffcs=false;
21345
21346 // show_progress=true;
21347 char tmpfilename[L_tmpnam];
21348 129 temp_name(tmpfilename);
21349 // char percent_done[30];
21350 129 bool catchup=false;
21351 byte tempbyte;
21352 129 word old_map_count=map_count;
21353
21354 129 byte old_quest_rules[QUESTRULES_NEW_SIZE] = {0};
21355 129 byte old_extra_rules[EXTRARULES_SIZE] = {0};
21356 129 byte old_midi_flags[MIDIFLAGS_SIZE] = {0};
21357
21358
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(get_bit(skip_flags, skip_rules))
21359 {
21360 memcpy(old_quest_rules, quest_rules, QUESTRULES_NEW_SIZE);
21361 memcpy(old_extra_rules, extra_rules, EXTRARULES_SIZE);
21362 }
21363
21364 129 memset(quest_rules, 0, QUESTRULES_NEW_SIZE); //clear here to prevent any kind of carryover -Z
21365 // memset(extra_rules, 0, EXTRARULES_SIZE); //clear here to prevent any kind of carryover -Z
21366
21367
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(get_bit(skip_flags, skip_midis))
21368 {
21369 memcpy(old_midi_flags, midi_flags, MIDIFLAGS_SIZE);
21370 }
21371
21372
21373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(!get_bit(skip_flags, skip_ffscript))
21374 {
21375 129 zScript.clear();
21376 129 globalmap.clear();
21377 129 genericmap.clear();
21378 129 ffcmap.clear();
21379 129 itemmap.clear();
21380 129 npcmap.clear();
21381 129 ewpnmap.clear();
21382 129 lwpnmap.clear();
21383 129 playermap.clear();
21384 129 dmapmap.clear();
21385 129 screenmap.clear();
21386 129 itemspritemap.clear();
21387 129 comboscriptmap.clear();
21388
21389
2/2
✓ Branch 0 taken 65919 times.
✓ Branch 1 taken 129 times.
66048 for(int32_t i=0; i<NUMSCRIPTFFC-1; i++)
21390 {
21391 65919 ffcmap[i].clear();
21392 65919 }
21393
21394 129 globalmap[0].slotname = "Slot 1:";
21395 129 globalmap[0].scriptname = "~Init";
21396 129 globalmap[0].update();
21397
21398
2/2
✓ Branch 0 taken 903 times.
✓ Branch 1 taken 129 times.
1032 for(int32_t i=1; i<NUMSCRIPTGLOBAL; i++)
21399 {
21400 903 globalmap[i].clear();
21401 903 }
21402
21403
2/2
✓ Branch 0 taken 32895 times.
✓ Branch 1 taken 129 times.
33024 for(int32_t i=0; i<NUMSCRIPTITEM-1; i++)
21404 {
21405 32895 itemmap[i].clear();
21406 32895 }
21407
21408 //new script types -- prevent carrying over to a quest that you load after reading them
21409 //e.g., a quest has an npc script, and you make a blank quest, that now believes that it has an npc script, too!
21410
2/2
✓ Branch 0 taken 32895 times.
✓ Branch 1 taken 129 times.
33024 for(int32_t i=0; i<NUMSCRIPTGUYS-1; i++)
21411 {
21412 32895 npcmap[i].clear();
21413 32895 }
21414
2/2
✓ Branch 0 taken 32895 times.
✓ Branch 1 taken 129 times.
33024 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21415 {
21416 32895 lwpnmap[i].clear();
21417 32895 }
21418
2/2
✓ Branch 0 taken 32895 times.
✓ Branch 1 taken 129 times.
33024 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21419 {
21420 32895 ewpnmap[i].clear();
21421 32895 }
21422
2/2
✓ Branch 0 taken 516 times.
✓ Branch 1 taken 129 times.
645 for(int32_t i=0; i<NUMSCRIPTPLAYER-1; i++)
21423 {
21424 516 playermap[i].clear();
21425 516 }
21426
2/2
✓ Branch 0 taken 32895 times.
✓ Branch 1 taken 129 times.
33024 for(int32_t i=0; i<NUMSCRIPTSDMAP-1; i++)
21427 {
21428 32895 dmapmap[i].clear();
21429 32895 }
21430
2/2
✓ Branch 0 taken 32895 times.
✓ Branch 1 taken 129 times.
33024 for(int32_t i=0; i<NUMSCRIPTSCREEN-1; i++)
21431 {
21432 32895 screenmap[i].clear();
21433 32895 }
21434
2/2
✓ Branch 0 taken 32895 times.
✓ Branch 1 taken 129 times.
33024 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE-1; i++)
21435 {
21436 32895 itemspritemap[i].clear();
21437 32895 }
21438
2/2
✓ Branch 0 taken 65919 times.
✓ Branch 1 taken 129 times.
66048 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA-1; i++)
21439 {
21440 65919 comboscriptmap[i].clear();
21441 65919 }
21442
2/2
✓ Branch 0 taken 65919 times.
✓ Branch 1 taken 129 times.
66048 for(int32_t i=0; i<NUMSCRIPTSGENERIC-1; i++)
21443 {
21444 65919 genericmap[i].clear();
21445 65919 }
21446
21447 129 reset_scripts();
21448 129 }
21449
21450 zquestheader tempheader;
21451 129 memset(&tempheader, 0, sizeof(zquestheader));
21452 129 zinfo tempzi;
21453 129 tempzi.clear();
21454 129 load_tmp_zi = &tempzi;
21455
21456 // oldquest flag is set when an unencrypted qst file is suspected.
21457 129 bool oldquest = false;
21458 129 int32_t open_error=0;
21459 129 PACKFILE *f=open_quest_file(&open_error, filename, show_progress);
21460
21461
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if (!f)
21462 {
21463 ASSERT(open_error != 0);
21464 return open_error;
21465 }
21466 char zinfofilename[2048];
21467 129 replace_extension(zinfofilename, filename, "zinfo", 2047);
21468 129 int32_t ret=0;
21469
21470 //header
21471 129 box_out("Reading Header...");
21472 129 ret=readheader(f, &tempheader, printmetadata);
21473
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
129 checkstatus(ret);
21474 129 box_out("okay.");
21475 129 box_eol();
21476
21477
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 36 times.
129 if(read_zinfo)
21478 {
21479 36 box_out("Reading ZInfo - ");
21480
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 35 times.
36 box_out(read_ext_zinfo ? "External..." : "Internal...");
21481
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 35 times.
36 if(read_ext_zinfo)
21482 {
21483 1 PACKFILE *inf=pack_fopen_password(zinfofilename, F_READ, "");
21484 1 ret=readzinfo(inf, tempzi, tempheader);
21485
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(inf) pack_fclose(inf);
21486
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 checkstatus(ret);
21487 1 }
21488 else
21489 {
21490 35 ret=readzinfo(f, tempzi, tempheader);
21491
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
35 checkstatus(ret);
21492 }
21493 36 box_out("okay.");
21494 36 box_eol();
21495 36 }
21496
21497
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(tempheader.zelda_version>=0x193)
21498 {
21499 dword section_id;
21500
21501 //section id
21502
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_mgetl(&section_id,f))
21503 {
21504 return qe_invalid;
21505 }
21506
21507 125 std::set<dword> seen_sections;
21508
21509
3/4
✓ Branch 0 taken 3017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2892 times.
✓ Branch 3 taken 125 times.
3017 while(!pack_feof(f))
21510 {
21511
2/4
✓ Branch 0 taken 2892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2892 times.
✗ Branch 3 not taken.
2892 if (seen_sections.contains(section_id))
21512 return qe_invalid;
21513
1/2
✓ Branch 0 taken 2892 times.
✗ Branch 1 not taken.
2892 seen_sections.insert(section_id);
21514
21515
2/4
✓ Branch 0 taken 2892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2892 times.
✗ Branch 3 not taken.
2892 if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
21516 {
21517 if (retval == qe_cancel)
21518 continue;
21519 checkstatus(retval);
21520 }
21521
21522
24/25
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 125 times.
✓ Branch 3 taken 125 times.
✓ Branch 4 taken 125 times.
✓ Branch 5 taken 113 times.
✓ Branch 6 taken 125 times.
✓ Branch 7 taken 125 times.
✓ Branch 8 taken 125 times.
✓ Branch 9 taken 125 times.
✓ Branch 10 taken 125 times.
✓ Branch 11 taken 125 times.
✓ Branch 12 taken 113 times.
✓ Branch 13 taken 113 times.
✓ Branch 14 taken 125 times.
✓ Branch 15 taken 125 times.
✓ Branch 16 taken 113 times.
✓ Branch 17 taken 113 times.
✓ Branch 18 taken 113 times.
✓ Branch 19 taken 113 times.
✓ Branch 20 taken 125 times.
✓ Branch 21 taken 125 times.
✓ Branch 22 taken 113 times.
✓ Branch 23 taken 113 times.
✗ Branch 24 not taken.
2892 switch(section_id)
21523 {
21524 case ID_RULES:
21525
21526 //rules
21527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21528 {
21529 box_out("found.");
21530 box_eol();
21531 catchup=false;
21532 }
21533
21534
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Rules...");
21535
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readrules(f, &tempheader);
21536
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21537
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21538
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21539 125 break;
21540
21541 case ID_STRINGS:
21542
21543 //strings
21544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21545 {
21546 box_out("found.");
21547 box_eol();
21548 catchup=false;
21549 }
21550
21551
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Strings...");
21552
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readstrings(f, &tempheader);
21553
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21554
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21555
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21556 125 break;
21557
21558 case ID_MISC:
21559
21560 //misc data
21561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21562 {
21563 box_out("found.");
21564 box_eol();
21565 catchup=false;
21566 }
21567
21568
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Misc. Data...");
21569
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readmisc(f, &tempheader, Misc);
21570
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21571
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21572
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21573 125 break;
21574
21575 case ID_TILES:
21576
21577 //tiles
21578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21579 {
21580 box_out("found.");
21581 box_eol();
21582 catchup=false;
21583 }
21584
21585
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Tiles...");
21586
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false);
21587
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21588
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21589
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21590 125 break;
21591
21592 case ID_COMBOS:
21593
21594 //combos
21595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21596 {
21597 box_out("found.");
21598 box_eol();
21599 catchup=false;
21600 }
21601
21602
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Combos...");
21603
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS);
21604 125 combosread=true;
21605
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21606
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21607
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21608 125 break;
21609
21610 case ID_COMBOALIASES:
21611
21612 //combo aliases
21613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(catchup)
21614 {
21615 box_out("found.");
21616 box_eol();
21617 catchup=false;
21618 }
21619
21620
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("Reading Combo Aliases...");
21621
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 ret=readcomboaliases(f, &tempheader, tempheader.zelda_version, tempheader.build);
21622
1/9
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
113 checkstatus(ret);
21623
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("okay.");
21624
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_eol();
21625 113 break;
21626
21627 case ID_CSETS:
21628
21629 //color data
21630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21631 {
21632 box_out("found.");
21633 box_eol();
21634 catchup=false;
21635 }
21636
21637
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Color Data...");
21638
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL);
21639
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21640
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21641
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21642 125 break;
21643
21644 case ID_MAPS:
21645
21646 //maps
21647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21648 {
21649 box_out("found.");
21650 box_eol();
21651 catchup=false;
21652 }
21653
21654
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Maps...");
21655
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readmaps(f, &tempheader);
21656 125 mapsread=true;
21657
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21658
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21659
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21660 125 break;
21661
21662 case ID_DMAPS:
21663
21664 //dmaps
21665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21666 {
21667 box_out("found.");
21668 box_eol();
21669 catchup=false;
21670 }
21671
21672
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading DMaps...");
21673
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS);
21674
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21675
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21676
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21677 125 break;
21678
21679 case ID_DOORS:
21680
21681 //door combo sets
21682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21683 {
21684 box_out("found.");
21685 box_eol();
21686 catchup=false;
21687 }
21688
21689
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Doors...");
21690
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readdoorcombosets(f, &tempheader);
21691
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21692
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21693
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21694 125 break;
21695
21696 case ID_ITEMS:
21697
21698 //items
21699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21700 {
21701 box_out("found.");
21702 box_eol();
21703 catchup=false;
21704 }
21705
21706
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Items...");
21707
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readitems(f, tempheader.zelda_version, tempheader.build);
21708
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21709
21710
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21711
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21712 125 break;
21713
21714 case ID_WEAPONS:
21715
21716 //weapons
21717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21718 {
21719 box_out("found.");
21720 box_eol();
21721 catchup=false;
21722 }
21723
21724
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Weapons...");
21725
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readweapons(f, &tempheader);
21726
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21727
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21728
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21729 125 break;
21730
21731 case ID_COLORS:
21732
21733 //misc. colors
21734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(catchup)
21735 {
21736 box_out("found.");
21737 box_eol();
21738 catchup=false;
21739 }
21740
21741
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("Reading Misc. Colors...");
21742
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 ret=readmisccolors(f, &tempheader, Misc);
21743
1/9
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
113 checkstatus(ret);
21744
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("okay.");
21745
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_eol();
21746 113 break;
21747
21748 case ID_ICONS:
21749
21750 //game icons
21751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(catchup)
21752 {
21753 box_out("found.");
21754 box_eol();
21755 catchup=false;
21756 }
21757
21758
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("Reading Game Icons...");
21759
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 ret=readgameicons(f, &tempheader, Misc);
21760
1/9
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
113 checkstatus(ret);
21761
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("okay.");
21762
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_eol();
21763 113 break;
21764
21765 case ID_INITDATA:
21766
21767 //initialization data
21768
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21769 {
21770 box_out("found.");
21771 box_eol();
21772 catchup=false;
21773 }
21774
21775
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Init. Data...");
21776
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readinitdata(f, &tempheader);
21777
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21778
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21779
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21780
21781
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
125 if(!get_bit(skip_flags, skip_subscreens))
21782 {
21783
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 98 times.
125 if(zinit.subscreen!=ssdtMAX) //not using custom subscreens
21784 {
21785
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 setupsubscreens();
21786
21787
2/2
✓ Branch 0 taken 13824 times.
✓ Branch 1 taken 27 times.
13851 for(int32_t i=0; i<MAXDMAPS; ++i)
21788 {
21789 13824 int32_t type=DMaps[i].type&dmfTYPE;
21790
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 13617 times.
13824 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
21791
1/2
✓ Branch 0 taken 13824 times.
✗ Branch 1 not taken.
13824 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
21792 13824 }
21793 27 }
21794 125 }
21795
21796
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
125 if(!get_bit(skip_flags, skip_sfx))
21797 {
21798 125 setupsfx();
21799 125 }
21800
21801
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!get_bit(skip_flags, skip_itemdropsets))
21802 {
21803
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 init_item_drop_sets();
21804 125 }
21805
21806
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
125 if(!get_bit(skip_flags, skip_favorites))
21807 {
21808 125 init_favorites();
21809 125 }
21810
21811 125 break;
21812
21813 case ID_GUYS:
21814
21815 //guys
21816
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21817 {
21818 box_out("found.");
21819 box_eol();
21820 catchup=false;
21821 }
21822
21823
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Custom Guy Data...");
21824
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readguys(f, &tempheader);
21825
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21826
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21827
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21828 125 break;
21829
21830 case ID_HEROSPRITES:
21831
21832 //player sprites
21833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(catchup)
21834 {
21835 box_out("found.");
21836 box_eol();
21837 catchup=false;
21838 }
21839
21840
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("Reading Custom Player Sprite Data...");
21841
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 ret=readherosprites(f, &tempheader);
21842
1/9
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
113 checkstatus(ret);
21843
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("okay.");
21844
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_eol();
21845 113 break;
21846
21847 case ID_SUBSCREEN:
21848
21849 //custom subscreens
21850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(catchup)
21851 {
21852 box_out("found.");
21853 box_eol();
21854 catchup=false;
21855 }
21856
21857
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("Reading Custom Subscreen Data...");
21858
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 ret=readsubscreens(f, &tempheader);
21859
1/9
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
113 checkstatus(ret);
21860
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("okay.");
21861
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_eol();
21862 113 break;
21863
21864 case ID_FFSCRIPT:
21865
21866 //Freeform combo scripts
21867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(catchup)
21868 {
21869 box_out("found.");
21870 box_eol();
21871 catchup=false;
21872 }
21873
21874
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("Reading FF Script Data...");
21875
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 ret=readffscript(f, &tempheader);
21876
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
113 checkstatus(ret);
21877
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("okay.");
21878
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_eol();
21879 113 break;
21880
21881 case ID_SFX:
21882
21883 //SFX data
21884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(catchup)
21885 {
21886 box_out("found.");
21887 box_eol();
21888 catchup=false;
21889 }
21890
21891
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("Reading SFX Data...");
21892
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 ret=readsfx(f, &tempheader);
21893
1/9
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
113 checkstatus(ret);
21894
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("okay.");
21895
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_eol();
21896 113 break;
21897
21898 case ID_MIDIS:
21899
21900 //midis
21901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21902 {
21903 box_out("found.");
21904 box_eol();
21905 catchup=false;
21906 }
21907
21908
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Tunes...");
21909
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readtunes(f, &tempheader, tunes);
21910
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21911
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21912
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21913 125 break;
21914
21915 case ID_CHEATS:
21916
21917 //cheat codes
21918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21919 {
21920 box_out("found.");
21921 box_eol();
21922 catchup=false;
21923 }
21924
21925
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Cheat Codes...");
21926
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readcheatcodes(f, &tempheader);
21927
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21928
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21929
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21930 125 break;
21931
21932 case ID_ITEMDROPSETS:
21933
21934 //item drop sets
21935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(catchup)
21936 {
21937 box_out("found.");
21938 box_eol();
21939 catchup=false;
21940 }
21941
21942
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("Reading Item Drop Sets...");
21943
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 ret=readitemdropsets(f, tempheader.zelda_version, tempheader.build);
21944
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
113 checkstatus(ret);
21945
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("okay.");
21946
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_eol();
21947 113 break;
21948
21949 case ID_FAVORITES:
21950
21951 //favorite combos and combo aliases
21952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(catchup)
21953 {
21954 box_out("found.");
21955 box_eol();
21956 catchup=false;
21957 }
21958
21959
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("Reading Favorite Combos...");
21960
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 ret=readfavorites(f, tempheader.zelda_version, tempheader.build);
21961
1/9
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
113 checkstatus(ret);
21962
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("okay.");
21963
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_eol();
21964 113 break;
21965
21966 default:
21967 if(!catchup)
21968 {
21969 box_out("Bad token! Searching...");
21970 box_eol();
21971 }
21972
21973 catchup=true;
21974 break;
21975 }
21976
21977
21978
1/2
✓ Branch 0 taken 2892 times.
✗ Branch 1 not taken.
2892 if(catchup)
21979 {
21980 //section id
21981 section_id=(section_id<<8);
21982
21983 if(!p_getc(&tempbyte,f))
21984 {
21985 return qe_invalid;
21986 }
21987
21988 section_id+=tempbyte;
21989 }
21990
21991 else
21992 {
21993 //section id
21994
3/4
✓ Branch 0 taken 2892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2767 times.
✓ Branch 3 taken 125 times.
2892 if(!pack_feof(f))
21995 {
21996
2/4
✓ Branch 0 taken 2767 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2767 times.
✗ Branch 3 not taken.
2767 if(!p_mgetl(&section_id,f))
21997 {
21998 return qe_invalid;
21999 }
22000 2767 }
22001 }
22002 }
22003
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 }
22004 else
22005 {
22006
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 std::vector<std::tuple<std::string, int32_t, std::function<int32_t()>>> hardcoded_sections = {
22007
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Rules", ID_RULES, [&](){ return readrules(f, &tempheader); }},
22008
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Strings", ID_STRINGS, [&](){ return readstrings(f, &tempheader); }},
22009
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Doors", ID_DOORS, [&](){ return readdoorcombosets(f, &tempheader); }},
22010
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "DMaps", ID_DMAPS, [&](){ return readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS); }},
22011
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Misc. Data", ID_MISC, [&](){ return readmisc(f, &tempheader, Misc); }},
22012
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Items", ID_ITEMS, [&](){ return readitems(f, tempheader.zelda_version, tempheader.build); }},
22013
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Weapons", ID_WEAPONS, [&](){ return readweapons(f, &tempheader); }},
22014
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Custom Guy Data", ID_GUYS, [&](){ return readguys(f, &tempheader); }},
22015
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Maps", ID_MAPS, [&](){ return readmaps(f, &tempheader); }},
22016
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Combos", ID_COMBOS, [&](){ return readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS); }},
22017
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Color Data", ID_CSETS, [&](){ return readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL); }},
22018
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Tiles", ID_TILES, [&](){ return readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false); }},
22019
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Tunes", ID_MIDIS, [&](){ return readtunes(f, &tempheader, tunes); }},
22020
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Cheat Codes", ID_CHEATS, [&](){ return readcheatcodes(f, &tempheader); }},
22021
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Init. Data", ID_INITDATA, [&](){ return readinitdata(f, &tempheader); }},
22022
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Custom Player Sprite Data", ID_HEROSPRITES, [&](){ return readherosprites2(f, -1, 0); }},
22023
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Up Default Item Drop Sets", ID_ITEMDROPSETS, [&](){ return readitemdropsets(f, -1, 0); }},
22024 };
22025
22026
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 68 times.
140 for (auto& [desc, section_id, fn] : hardcoded_sections)
22027 {
22028 // Would be nice, but old sections mostly did not save section sizes. We could advance by
22029 // a specific amount, but it'd be a lot of work to get it right. So, for old quests, let's just
22030 // read all the sections even if requested to skip some.
22031 // if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
22032 // {
22033 // if (retval == qe_cancel)
22034 // continue;
22035 // checkstatus(retval);
22036 // }
22037
22038
3/6
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 68 times.
✗ Branch 5 not taken.
136 box_out(fmt::format("Reading {}...", desc).c_str());
22039
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 ret = fn();
22040
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 68 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
68 checkstatus(ret);
22041
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 box_out("okay.");
22042
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 box_eol();
22043 }
22044
22045
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 if(!get_bit(skip_flags, skip_subscreens))
22046 {
22047
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 setupsubscreens();
22048
22049
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 4 times.
2052 for(int32_t i=0; i<MAXDMAPS; ++i)
22050 {
22051 2048 int32_t type=DMaps[i].type&dmfTYPE;
22052
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 2036 times.
2048 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22053
1/2
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
2048 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
22054 2048 }
22055 4 }
22056
22057
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 box_out("Setting Up Default Sound Effects...");
22058
22059
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(!get_bit(skip_flags, skip_sfx))
22060 4 setupsfx();
22061
22062
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 box_out("okay.");
22063
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 box_eol();
22064
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 }
22065
22066 129 init_spritelists();
22067
22068 // check data
22069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(f)
22070 {
22071 129 pack_fclose(f);
22072 129 }
22073 129 clear_quest_tmpfile();
22074
22075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(!oldquest)
22076 {
22077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(exists(tmpfilename))
22078 {
22079 delete_file(tmpfilename);
22080 }
22081 129 }
22082
22083
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if(fixffcs && combosread && mapsread)
22084 {
22085 for(int32_t i=0; i<map_count; i++)
22086 {
22087 for(int32_t j=0; j<MAPSCRS; j++)
22088 {
22089 for(int32_t m=0; m<32; m++)
22090 {
22091 if(combobuf[TheMaps[(i*MAPSCRS)+j].ffcs[m].getData()].type == cCHANGE)
22092 TheMaps[(i*MAPSCRS)+j].ffcs[m].flags|=ffCHANGER;
22093 }
22094 }
22095 }
22096 }
22097
22098
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 29 times.
129 if(get_qr(qr_CONTFULL_DEP))
22099 {
22100 29 set_qr(qr_CONTFULL_DEP, 0);
22101 29 set_bit(zinit.misc, idM_CONTPERCENT, 1);
22102 29 zinit.cont_heart=100;
22103 29 zinit.start_heart=zinit.hc;
22104 29 }
22105
22106 129 box_out("Done.");
22107 129 box_eol();
22108 129 box_end(false);
22109
22110
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(!get_bit(skip_flags, skip_header))
22111 {
22112 129 memcpy(Header, &tempheader, sizeof(tempheader));
22113 129 }
22114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(!get_bit(skip_flags, skip_zinfo))
22115 {
22116 129 ZI.copyFrom(tempzi);
22117 129 }
22118
22119
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(get_bit(skip_flags, skip_maps))
22120 {
22121 map_count=old_map_count;
22122 }
22123
22124
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(get_bit(skip_flags, skip_rules))
22125 {
22126 memcpy(quest_rules, old_quest_rules, QUESTRULES_NEW_SIZE);
22127 memcpy(extra_rules, old_extra_rules, EXTRARULES_SIZE);
22128 }
22129
22130
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(get_bit(skip_flags, skip_midis))
22131 {
22132 memcpy(midi_flags, old_midi_flags, MIDIFLAGS_SIZE);
22133 }
22134
22135 //Debug FFCore.quest_format[]
22136 129 al_trace("Quest made in ZC Version: %x\n", FFCore.quest_format[vZelda]);
22137 129 al_trace("Quest made in ZC Build: %d\n", FFCore.quest_format[vBuild]);
22138 129 al_trace("Quest Section 'Header' is Version: %d\n", FFCore.quest_format[vHeader]);
22139 129 al_trace("Quest Section 'Rules' is Version: %d\n", FFCore.quest_format[vRules]);
22140 129 al_trace("Quest Section 'Strings' is Version: %d\n", FFCore.quest_format[vStrings]);
22141 129 al_trace("Quest Section 'Misc' is Version: %d\n", FFCore.quest_format[vMisc]);
22142 129 al_trace("Quest Section 'Tiles' is Version: %d\n", FFCore.quest_format[vTiles]);
22143 129 al_trace("Quest Section 'Combos' is Version: %d\n", FFCore.quest_format[vCombos]);
22144 129 al_trace("Quest Section 'CSets' is Version: %d\n", FFCore.quest_format[vCSets]);
22145 129 al_trace("Quest Section 'Maps' is Version: %d\n", FFCore.quest_format[vMaps]);
22146 129 al_trace("Quest Section 'DMaps' is Version: %d\n", FFCore.quest_format[vDMaps]);
22147 129 al_trace("Quest Section 'Doors' is Version: %d\n", FFCore.quest_format[vDoors]);
22148 129 al_trace("Quest Section 'Items' is Version: %d\n", FFCore.quest_format[vItems]);
22149 129 al_trace("Quest Section 'Weapons' is Version: %d\n", FFCore.quest_format[vWeaponSprites]);
22150 129 al_trace("Quest Section 'Colors' is Version: %d\n", FFCore.quest_format[vColours]);
22151 129 al_trace("Quest Section 'Icons' is Version: %d\n", FFCore.quest_format[vIcons]);
22152 //al_trace("Quest Section 'Gfx Pack' is Version: %d; qst.cpp doesn't read this!\n", FFCore.quest_format[vGfxPack]);
22153 129 al_trace("Quest Section 'InitData' is Version: %d\n", FFCore.quest_format[vInitData]);
22154 129 al_trace("Quest Section 'Guys' is Version: %d\n", FFCore.quest_format[vGuys]);
22155 129 al_trace("Quest Section 'MIDIs' is Version: %d\n", FFCore.quest_format[vMIDIs]);
22156 129 al_trace("Quest Section 'Cheats' is Version: %d\n", FFCore.quest_format[vCheats]);
22157 //al_trace("Quest Section 'Save Format' is Version: %d; qst.cpp doesn't read this!\n", FFCore.quest_format[vSaveformat]);
22158 129 al_trace("Quest Section 'Combo Aliases' is Version: %d\n", FFCore.quest_format[vComboAliases]);
22159 129 al_trace("Quest Section 'Player Sprites' is Version: %d\n", FFCore.quest_format[vHeroSprites]);
22160 129 al_trace("Quest Section 'Subscreen' is Version: %d\n", FFCore.quest_format[vSubscreen]);
22161 129 al_trace("Quest Section 'Dropsets' is Version: %d\n", FFCore.quest_format[vItemDropsets]);
22162 129 al_trace("Quest Section 'FFScript' is Version: %d\n", FFCore.quest_format[vFFScript]);
22163 129 al_trace("Quest Section 'SFX' is Version: %d\n", FFCore.quest_format[vSFX]);
22164 129 al_trace("Quest Section 'Favorites' is Version: %d\n", FFCore.quest_format[vFavourites]);
22165 129 al_trace("Quest Section 'CompatRules' is Version: %d\n", FFCore.quest_format[vCompatRule]);
22166 //Print metadata for versions under 2.10 here. Bleah.
22167
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if( FFCore.quest_format[vZelda] < 0x210 )
22168 {
22169 4 zprint2("\n[ZQUEST CREATOR METADATA]\n");
22170
22171
1/13
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
4 switch(FFCore.quest_format[vZelda])
22172 {
22173 case 0x193:
22174 {
22175 zprint2("Last saved in ZC Editor Version: 1.93, Beta %d\n", FFCore.quest_format[vBuild]); break;
22176 }
22177 case 0x192:
22178 {
22179 zprint2("Last saved in ZC Editor Version: 1.92, Beta %d\n", FFCore.quest_format[vBuild]); break;
22180 }
22181 case 0x190:
22182 {
22183 4 zprint2("Last saved in ZC Editor Version: 1.90");
22184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22185 4 else zprint2("\n");
22186 4 break;
22187 }
22188 case 0x188:
22189 {
22190 zprint2("Last saved in ZC Editor Version: 1.88");
22191 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22192 else zprint2("\n");
22193 break;
22194 }
22195 case 0x187:
22196 {
22197 zprint2("Last saved in ZC Editor Version: 1.87");
22198 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22199 else zprint2("\n");
22200 break;
22201 }
22202 case 0x186:
22203 {
22204 zprint2("Last saved in ZC Editor Version: 1.86");
22205 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22206 else zprint2("\n");
22207 break;
22208 }
22209 case 0x185:
22210 {
22211 zprint2("Last saved in ZC Editor Version: 1.85");
22212 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22213 else zprint2("\n");
22214 break;
22215 }
22216 case 0x184:
22217 {
22218 zprint2("Last saved in ZC Editor Version: 1.84");
22219 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22220 else zprint2("\n");
22221 break;
22222 }
22223 case 0x183:
22224 {
22225 zprint2("Last saved in ZC Editor Version: 1.83");
22226 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22227 else zprint2("\n");
22228 break;
22229 }
22230 case 0x182:
22231 {
22232 zprint2("Last saved in ZC Editor Version: 1.82");
22233 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22234 else zprint2("\n");
22235 break;
22236 }
22237 case 0x181:
22238 {
22239 zprint2("Last saved in ZC Editor Version: 1.81");
22240 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22241 else zprint2("\n");
22242 break;
22243 }
22244 case 0x180:
22245 {
22246 zprint2("Last saved in ZC Editor Version: 1.80");
22247 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22248 else zprint2("\n");
22249 break;
22250 }
22251 default:
22252 {
22253 zprint2("Last saved in ZC Editor Version: %x, Beta %d\n", FFCore.quest_format[vZelda],FFCore.quest_format[vBuild]); break;
22254 }
22255 }
22256 4 }
22257
22258 129 return qe_OK;
22259
22260 invalid:
22261 box_out("error.");
22262 box_eol();
22263 box_end(true);
22264
22265 if(f)
22266 {
22267 pack_fclose(f);
22268 }
22269
22270 if(!oldquest)
22271 {
22272 if(exists(tmpfilename))
22273 {
22274 delete_file(tmpfilename);
22275 }
22276 }
22277
22278 return qe_invalid;
22279
22280 129 }
22281
22282 129 int32_t loadquest(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata, bool report, byte qst_num)
22283 {
22284 129 const char* basename = get_filename(filename);
22285 129 zapp_reporting_add_breadcrumb("load_quest", basename);
22286 129 zapp_reporting_set_tag("qst.filename", basename);
22287
22288 129 loading_qst_name = filename;
22289 129 loading_qst_num = qst_num;
22290 // In CI, builds are cached for replay tests, which can result in their build dates being earlier than what it would be locally.
22291 // So to avoid a more-recently updated .qst file from hitting the "last saved in a newer version" prompt, we disable in CI.
22292
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if (!is_ci())
22293 loadquest_report = report;
22294 129 int32_t ret = _lq_int(filename, Header, Misc, tunes, show_progress, skip_flags, printmetadata);
22295 129 load_tmp_zi = NULL;
22296 129 loading_qst_name = NULL;
22297 129 loadquest_report = false;
22298 129 loading_qst_num = 0;
22299
22300 129 zapp_reporting_set_tag("qst.title", Header->title);
22301 129 zapp_reporting_set_tag("qst.zc_version", Header->getVerStr());
22302
22303 129 return ret;
22304 }
22305